|
| 1 | +(function () { |
| 2 | + 'use strict'; |
| 3 | + |
| 4 | + describe('Users Admin Route Tests', function () { |
| 5 | + // Initialize global variables |
| 6 | + var $scope, |
| 7 | + Authentication; |
| 8 | + |
| 9 | + //We can start by loading the main application module |
| 10 | + beforeEach(module(ApplicationConfiguration.applicationModuleName)); |
| 11 | + |
| 12 | + // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_). |
| 13 | + // This allows us to inject a service but then attach it to a variable |
| 14 | + // with the same name as the service. |
| 15 | + beforeEach(inject(function ($rootScope, _Authentication_) { |
| 16 | + // Set a new global scope |
| 17 | + $scope = $rootScope.$new(); |
| 18 | + Authentication = _Authentication_; |
| 19 | + })); |
| 20 | + |
| 21 | + describe('Route Config', function () { |
| 22 | + describe('Main Route', function () { |
| 23 | + var mainstate; |
| 24 | + beforeEach(inject(function ($state) { |
| 25 | + mainstate = $state.get('admin.users'); |
| 26 | + })); |
| 27 | + |
| 28 | + it('Should have the correct URL', function () { |
| 29 | + expect(mainstate.url).toEqual('/users'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('Should not be abstract', function () { |
| 33 | + expect(mainstate.abstract).toBe(undefined); |
| 34 | + }); |
| 35 | + |
| 36 | + it('Should have templateUrl', function () { |
| 37 | + expect(mainstate.templateUrl).toBe('modules/users/client/views/admin/list-users.client.view.html'); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | + describe('View Route', function () { |
| 42 | + var viewstate; |
| 43 | + beforeEach(inject(function ($state) { |
| 44 | + viewstate = $state.get('admin.user'); |
| 45 | + })); |
| 46 | + |
| 47 | + it('Should have the correct URL', function () { |
| 48 | + expect(viewstate.url).toEqual('/users/:userId'); |
| 49 | + }); |
| 50 | + |
| 51 | + it('Should not be abstract', function () { |
| 52 | + expect(viewstate.abstract).toBe(undefined); |
| 53 | + }); |
| 54 | + |
| 55 | + it('Should have templateUrl', function () { |
| 56 | + expect(viewstate.templateUrl).toBe('modules/users/client/views/admin/view-user.client.view.html'); |
| 57 | + }); |
| 58 | + }); |
| 59 | + |
| 60 | + describe('Edit Route', function () { |
| 61 | + var editstate; |
| 62 | + beforeEach(inject(function ($state) { |
| 63 | + editstate = $state.get('admin.user-edit'); |
| 64 | + })); |
| 65 | + |
| 66 | + it('Should have the correct URL', function () { |
| 67 | + expect(editstate.url).toEqual('/users/:userId/edit'); |
| 68 | + }); |
| 69 | + |
| 70 | + it('Should not be abstract', function () { |
| 71 | + expect(editstate.abstract).toBe(undefined); |
| 72 | + }); |
| 73 | + |
| 74 | + it('Should have templateUrl', function () { |
| 75 | + expect(editstate.templateUrl).toBe('modules/users/client/views/admin/edit-user.client.view.html'); |
| 76 | + }); |
| 77 | + }); |
| 78 | + |
| 79 | + describe('Handle Trailing Slash', function () { |
| 80 | + beforeEach(inject(function ($state, $rootScope, _Authentication_) { |
| 81 | + Authentication.user = { |
| 82 | + name: 'user', |
| 83 | + roles: ['admin'] |
| 84 | + }; |
| 85 | + |
| 86 | + $state.go('admin.users'); |
| 87 | + $rootScope.$digest(); |
| 88 | + })); |
| 89 | + |
| 90 | + it('Should remove trailing slash', inject(function ($state, $location, $rootScope) { |
| 91 | + $location.path('admin/users/'); |
| 92 | + $rootScope.$digest(); |
| 93 | + |
| 94 | + expect($location.path()).toBe('/admin/users'); |
| 95 | + expect($state.current.templateUrl).toBe('modules/users/client/views/admin/list-users.client.view.html'); |
| 96 | + })); |
| 97 | + }); |
| 98 | + |
| 99 | + }); |
| 100 | + }); |
| 101 | +})(); |
0 commit comments