Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
birdofpreyru committed Feb 9, 2017
1 parent 8cc98f7 commit 80d9b3c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/account/logout/logout.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import angular from 'angular'
describe('Logout Controller', function() {
var controller
var fakeWindow = {
// Without the `angular` field our fake window will crush
// `[email protected]` and higher!
angular: {
callbacks: {}
},
location: {
href: ''
}
Expand All @@ -15,14 +20,11 @@ describe('Logout Controller', function() {
angular.mock.module('tc.account', function($provide) {
$provide.value('$window', fakeWindow)
})

bard.inject(this, '$controller', 'TcAuthService', '$window', '$q', 'CONSTANTS')

bard.mockService(TcAuthService, {
logout: $q.when({}),
_default: $q.when({})
})

controller = $controller('LogoutController')
})

Expand Down
5 changes: 5 additions & 0 deletions app/services/helpers.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const mockData = require('../../tests/test-helpers/mock-data')
describe('Helper Service', function() {

var fakeWindow = {
// Without the `angular` field our fake window will crush
// `[email protected]` and higher!
angular: {
callbacks: {}
},
location: {
href: '/'
},
Expand Down
5 changes: 5 additions & 0 deletions app/services/jwtInterceptor.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ describe('JWT Interceptor Service', function() {
})
},
fakeWindow = {
// Without the `angular` field our fake window will crush
// `[email protected]` and higher!
angular: {
callbacks: {}
},
location: ''
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "karma start --tc --test"
},
"devDependencies": {
"angular-mocks": "^1.4.9",
"angular-mocks": "^1.6.2",
"appirio-tech-webpack-config": "^0.3.8",
"babel-polyfill": "^6.7.2",
"bardjs": "^0.1.8",
Expand Down

0 comments on commit 80d9b3c

Please sign in to comment.