forum-options-test.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Ember from 'ember';
  2. import { module, test } from 'qunit';
  3. import startApp from '../helpers/start-app';
  4. import getToastMessage from '../helpers/toast-message';
  5. import createUser from '../helpers/create-user';
  6. var application, container, auth;
  7. module('Acceptance: Forum Options', {
  8. beforeEach: function() {
  9. application = startApp();
  10. container = application.__container__;
  11. auth = container.lookup('service:auth');
  12. },
  13. afterEach: function() {
  14. Ember.run(application, 'destroy');
  15. Ember.$.mockjax.clear();
  16. }
  17. });
  18. test('visiting /options redirects to /options/forum-options', function(assert) {
  19. var user = createUser();
  20. auth.setProperties({
  21. 'isAuthenticated': true,
  22. 'user': user
  23. });
  24. assert.expect(1);
  25. visit('/options');
  26. andThen(function() {
  27. assert.equal(currentPath(), 'options.forum');
  28. });
  29. });
  30. test('/options/forum-options form can be submitted', function(assert) {
  31. var user = createUser();
  32. auth.setProperties({
  33. 'isAuthenticated': true,
  34. 'user': user
  35. });
  36. Ember.$.mockjax({
  37. url: '/api/users/' + user.id + '/forum-options/',
  38. status: 200,
  39. responseText: {
  40. 'detail': 'API endpoint was called!'
  41. }
  42. });
  43. assert.expect(1);
  44. visit('/options/forum-options/');
  45. click('.panel-form .panel-body .btn');
  46. click('.panel-form .panel-footer .btn-primary');
  47. andThen(function() {
  48. assert.equal(getToastMessage(), 'API endpoint was called!');
  49. });
  50. });