application-test.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {
  2. moduleFor,
  3. test
  4. } from 'ember-qunit';
  5. var document_title = document.title;
  6. moduleFor('route:application', 'ApplicationRoute', {
  7. afterEach: function() {
  8. document.title = document_title;
  9. }
  10. });
  11. test('it exists', function(assert) {
  12. assert.expect(1);
  13. var route = this.subject();
  14. assert.ok(route);
  15. });
  16. test('error', function(assert) {
  17. assert.expect(1);
  18. var route = this.subject();
  19. route.set('settings', {'forum_name': 'Test Forum'});
  20. // generic error
  21. route.send('error', {status: 123});
  22. assert.equal(document.title, 'Error | Test Forum');
  23. });
  24. test('setTitle', function(assert) {
  25. assert.expect(5);
  26. var route = this.subject();
  27. route.set('settings', {'forum_name': 'Test Forum'});
  28. // string argument
  29. route.send('setTitle', 'Welcome!');
  30. assert.equal(document.title, 'Welcome! | Test Forum');
  31. // object argument
  32. route.send('setTitle', {title: 'Thread'});
  33. assert.equal(document.title, 'Thread | Test Forum');
  34. // object argument with parent
  35. route.send('setTitle', {title: 'Test Thread', parent: 'Support'});
  36. assert.equal(document.title, 'Test Thread | Support | Test Forum');
  37. // object argument with page
  38. route.send('setTitle', {title: 'Test Thread', page: 12});
  39. assert.equal(document.title, 'Test Thread (page 12) | Test Forum');
  40. // object argument with page and parent
  41. route.send('setTitle', {title: 'Test Thread', page: 12, parent: 'Support'});
  42. assert.equal(document.title, 'Test Thread (page 12) | Support | Test Forum');
  43. });