123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import Ember from 'ember';
- import { module, test } from 'qunit';
- import startApp from '../helpers/start-app';
- var application;
- module('Acceptance: Application Error Handler', {
- beforeEach: function() {
- application = startApp();
- },
- afterEach: function() {
- Ember.run(application, 'destroy');
- Ember.$.mockjax.clear();
- }
- });
- test('some unhandled error occured', function(assert) {
- Ember.$.mockjax({
- url: "/api/legal-pages/privacy-policy/",
- status: 500,
- responseText: {
- 'detail': 'The kek'
- }
- });
- visit('/privacy-policy');
- andThen(function() {
- assert.equal(currentPath(), 'error');
- });
- });
- test('app went away', function(assert) {
- Ember.$.mockjax({
- url: "/api/legal-pages/privacy-policy/",
- status: 0,
- responseText: {
- 'detail': 'Connection rejected'
- }
- });
- visit('/privacy-policy');
- andThen(function() {
- assert.equal(currentPath(), 'error-0');
- });
- });
- test('not found', function(assert) {
- Ember.$.mockjax({
- url: "/api/legal-pages/privacy-policy/",
- status: 404,
- responseText: {
- 'detail': 'Not found'
- }
- });
- visit('/privacy-policy');
- andThen(function() {
- assert.equal(currentPath(), 'error-404');
- });
- });
- test('permission denied', function(assert) {
- Ember.$.mockjax({
- url: "/api/legal-pages/privacy-policy/",
- status: 403,
- responseText: {
- 'detail': 'Permission denied'
- }
- });
- visit('/privacy-policy');
- andThen(function() {
- assert.equal(currentPath(), 'error-403');
- });
- });
- test('permission denied with reason', function(assert) {
- Ember.$.mockjax({
- url: "/api/legal-pages/privacy-policy/",
- status: 403,
- responseText: {
- 'detail': 'Lorem ipsum dolor met.'
- }
- });
- visit('/privacy-policy');
- andThen(function() {
- assert.equal(currentPath(), 'error-403');
- var $e = find('.lead');
- assert.equal(Ember.$.trim($e.text()), 'Lorem ipsum dolor met.');
- });
- });
- test('not found route', function(assert) {
- visit('/this-url-really-doesnt-exist');
- andThen(function() {
- assert.equal(currentPath(), 'error-404');
- });
- });
|