page-title-test.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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('setPlaceholderTitle changes document title to one defined for index', function(assert) {
  33. assert.expect(1);
  34. var service = this.subject();
  35. service.set('forumName', 'Placeholder Test Forum');
  36. // no index title is set
  37. service.setPlaceholderTitle();
  38. assert.equal(document.title, 'Placeholder Test Forum');
  39. });
  40. test('setIndexTitle changes document title to one defined for index', function(assert) {
  41. assert.expect(2);
  42. var service = this.subject();
  43. service.set('forumName', 'Test Forum');
  44. // no index title is set
  45. service.setIndexTitle();
  46. assert.equal(document.title, 'Test Forum');
  47. // index title is set
  48. service.set('indexTitle', 'Test Forum Index');
  49. service.setIndexTitle();
  50. assert.equal(document.title, 'Test Forum Index');
  51. });