page-title-test.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {
  2. moduleFor,
  3. test
  4. } from 'ember-qunit';
  5. moduleFor('service:page-title', {
  6. needs: ['initializer:misago-settings']
  7. });
  8. test('it exists', function(assert) {
  9. var service = this.subject();
  10. assert.ok(service);
  11. });
  12. test('setTitle changes document title', function(assert) {
  13. assert.expect(5);
  14. var service = this.subject();
  15. service.set('forumName', 'Test Forum');
  16. // string argument
  17. service.setTitle('Welcome!');
  18. assert.equal(document.title, 'Welcome! | Test Forum');
  19. // object argument
  20. service.setTitle({title: 'Thread'});
  21. assert.equal(document.title, 'Thread | Test Forum');
  22. // object argument with parent
  23. service.setTitle({title: 'Test Thread', parent: 'Support'});
  24. assert.equal(document.title, 'Test Thread | Support | Test Forum');
  25. // object argument with page
  26. service.setTitle({title: 'Test Thread', page: 12});
  27. assert.equal(document.title, 'Test Thread (page 12) | Test Forum');
  28. // object argument with page and parent
  29. service.setTitle({title: 'Test Thread', page: 12, parent: 'Support'});
  30. assert.equal(document.title, 'Test Thread (page 12) | Support | Test Forum');
  31. });
  32. test('setIndexTitle changes document title to one defined for index', function(assert) {
  33. assert.expect(2);
  34. var service = this.subject();
  35. service.set('forumName', 'Test Forum');
  36. // no index title is set
  37. service.setIndexTitle();
  38. assert.equal(document.title, 'Test Forum');
  39. // index title is set
  40. service.set('indexTitle', 'Test Forum Index');
  41. service.setIndexTitle();
  42. assert.equal(document.title, 'Test Forum Index');
  43. });