application-test.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. var route = this.subject();
  13. assert.ok(route);
  14. });
  15. test('error', function(assert) {
  16. var route = this.subject();
  17. route.set('settings', {'forum_name': 'Test Forum'});
  18. // generic error
  19. route.send('error', {status: 123});
  20. assert.equal(document.title, 'Error | Test Forum');
  21. });
  22. test('setTitle', function(assert) {
  23. var route = this.subject();
  24. route.set('settings', {'forum_name': 'Test Forum'});
  25. // string argument
  26. route.send('setTitle', 'Welcome!');
  27. assert.equal(document.title, 'Welcome! | Test Forum');
  28. // object argument
  29. route.send('setTitle', {title: 'Thread'});
  30. assert.equal(document.title, 'Thread | Test Forum');
  31. // object argument with parent
  32. route.send('setTitle', {title: 'Test Thread', parent: 'Support'});
  33. assert.equal(document.title, 'Test Thread | Support | Test Forum');
  34. // object argument with page
  35. route.send('setTitle', {title: 'Test Thread', page: 12});
  36. assert.equal(document.title, 'Test Thread (page 12) | Test Forum');
  37. // object argument with page and parent
  38. route.send('setTitle', {title: 'Test Thread', page: 12, parent: 'Support'});
  39. assert.equal(document.title, 'Test Thread (page 12) | Support | Test Forum');
  40. });