|
47 | 47 | spyOn(Notification, 'error');
|
48 | 48 | spyOn(Notification, 'success');
|
49 | 49 |
|
| 50 | + // Ignore parent template get on state transitions |
| 51 | + $httpBackend.whenGET('/modules/core/client/views/home.client.view.html').respond(200); |
| 52 | + $httpBackend.whenGET('/modules/core/client/views/400.client.view.html').respond(200); |
| 53 | + |
50 | 54 | // Initialize the Authentication controller
|
51 | 55 | AuthenticationController = $controller('AuthenticationController as vm', {
|
52 | 56 | $scope: scope
|
53 | 57 | });
|
54 | 58 | }));
|
55 | 59 |
|
56 | 60 | describe('$scope.signin()', function () {
|
57 |
| - it('should login with a correct username and password', function () { |
| 61 | + it('should login with a correct user and password', inject(function ($templateCache) { |
| 62 | + $templateCache.put('/modules/core/client/views/home.client.view.html', ''); |
| 63 | + |
58 | 64 | // Test expected GET request
|
59 | 65 | $httpBackend.when('POST', '/api/auth/signin').respond(200, { username: 'Fred' });
|
60 | 66 |
|
|
64 | 70 | // Test scope value
|
65 | 71 | expect(scope.vm.authentication.user.username).toEqual('Fred');
|
66 | 72 | expect($location.url()).toEqual('/');
|
67 |
| - }); |
| 73 | + })); |
68 | 74 |
|
69 |
| - it('should login with a correct email and password', function () { |
| 75 | + it('should login with a correct email and password', inject(function ($templateCache) { |
| 76 | + $templateCache.put('/modules/core/client/views/home.client.view.html', ''); |
70 | 77 | // Test expected GET request
|
71 |
| - $httpBackend.when('POST', 'api/auth/signin').respond(200, { email: '[email protected]' }); |
| 78 | + $httpBackend.when('POST', '/api/auth/signin').respond(200, { email: '[email protected]' }); |
72 | 79 |
|
73 | 80 | scope.vm.signin(true);
|
74 | 81 | $httpBackend.flush();
|
75 | 82 |
|
76 | 83 | // Test scope value
|
77 | 84 | expect(scope.vm.authentication.user.email).toEqual('[email protected]');
|
78 | 85 | expect($location.url()).toEqual('/');
|
79 |
| - }); |
| 86 | + })); |
80 | 87 |
|
81 | 88 | it('should be redirected to previous state after successful login',
|
82 | 89 | inject(function (_$state_) {
|
|
136 | 143 | });
|
137 | 144 |
|
138 | 145 | describe('$scope.signup()', function () {
|
139 |
| - it('should register with correct data', function () { |
| 146 | + it('should register with correct data', inject(function ($templateCache) { |
| 147 | + $templateCache.put('/modules/core/client/views/home.client.view.html', ''); |
| 148 | + |
140 | 149 | // Test expected GET request
|
141 | 150 | scope.vm.authentication.user = 'Fred';
|
142 | 151 | $httpBackend.when('POST', '/api/auth/signup').respond(200, { username: 'Fred' });
|
|
148 | 157 | expect(scope.vm.authentication.user.username).toBe('Fred');
|
149 | 158 | expect(Notification.success).toHaveBeenCalledWith({ message: '<i class="glyphicon glyphicon-ok"></i> Signup successful!' });
|
150 | 159 | expect($location.url()).toBe('/');
|
151 |
| - }); |
| 160 | + })); |
152 | 161 |
|
153 | 162 | it('should fail to register with duplicate Username', function () {
|
154 | 163 | // Test expected POST request
|
|
0 commit comments