Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 80d9b3c

Browse files
committed
Fixed unit tests
The updated of `angular-mocks` up to v1.6.2 broke those unit tests, which injected a fake window object into environment. Some functions inside `angular-mocks` assume that `window.angular.callbacks` exists, and they crush otherwise. Adding such field into all fake windows injected by broken tests resolved the issue.
1 parent 8cc98f7 commit 80d9b3c

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

Diff for: app/account/logout/logout.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import angular from 'angular'
44
describe('Logout Controller', function() {
55
var controller
66
var fakeWindow = {
7+
// Without the `angular` field our fake window will crush
8+
// `[email protected]` and higher!
9+
angular: {
10+
callbacks: {}
11+
},
712
location: {
813
href: ''
914
}
@@ -15,14 +20,11 @@ describe('Logout Controller', function() {
1520
angular.mock.module('tc.account', function($provide) {
1621
$provide.value('$window', fakeWindow)
1722
})
18-
1923
bard.inject(this, '$controller', 'TcAuthService', '$window', '$q', 'CONSTANTS')
20-
2124
bard.mockService(TcAuthService, {
2225
logout: $q.when({}),
2326
_default: $q.when({})
2427
})
25-
2628
controller = $controller('LogoutController')
2729
})
2830

Diff for: app/services/helpers.service.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ const mockData = require('../../tests/test-helpers/mock-data')
55
describe('Helper Service', function() {
66

77
var fakeWindow = {
8+
// Without the `angular` field our fake window will crush
9+
// `[email protected]` and higher!
10+
angular: {
11+
callbacks: {}
12+
},
813
location: {
914
href: '/'
1015
},

Diff for: app/services/jwtInterceptor.service.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ describe('JWT Interceptor Service', function() {
3333
})
3434
},
3535
fakeWindow = {
36+
// Without the `angular` field our fake window will crush
37+
// `[email protected]` and higher!
38+
angular: {
39+
callbacks: {}
40+
},
3641
location: ''
3742
}
3843

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test": "karma start --tc --test"
99
},
1010
"devDependencies": {
11-
"angular-mocks": "^1.4.9",
11+
"angular-mocks": "^1.6.2",
1212
"appirio-tech-webpack-config": "^0.3.8",
1313
"babel-polyfill": "^6.7.2",
1414
"bardjs": "^0.1.8",

0 commit comments

Comments
 (0)