routed-links-test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import Ember from 'ember';
  2. import PreloadStore from 'misago/services/preload-store';
  3. import { module, test } from 'qunit';
  4. import startApp from '../helpers/start-app';
  5. var application;
  6. module('Acceptance: Routed Links Component', {
  7. beforeEach: function() {
  8. PreloadStore.set('staticUrl', '/static/');
  9. application = startApp();
  10. },
  11. afterEach: function() {
  12. Ember.run(application, 'destroy');
  13. Ember.$.mockjax.clear();
  14. PreloadStore.set('staticUrl', '/');
  15. }
  16. });
  17. test('app link within component gets routed by ember', function(assert) {
  18. assert.expect(1);
  19. Ember.$.mockjax({
  20. url: '/api/legal-pages/privacy-policy/',
  21. status: 403,
  22. responseText: {
  23. 'ban': {
  24. 'expires_on': null,
  25. 'message': {
  26. 'plain': 'You are banned. See /terms-of-service/.',
  27. 'html': '<p>You are banned. See <a class="posted-link" href="/terms-of-service/">/terms-of-service/</a>.</p>'
  28. }
  29. }
  30. }
  31. });
  32. Ember.$.mockjax({
  33. url: '/api/legal-pages/terms-of-service/',
  34. responseText: {
  35. 'id': 'terms-of-service',
  36. 'title': 'Terms of service',
  37. 'link': '',
  38. 'body': '<p>Terms of service are working!</p>'
  39. }
  40. });
  41. visit('/privacy-policy');
  42. click('.error-message .posted-link');
  43. andThen(function() {
  44. assert.equal(currentPath(), 'terms-of-service');
  45. });
  46. });