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

Commit 2d4c680

Browse files
author
Vikas Agarwal
committed
Github issue #919, Few Unit tests failing after angular 1.6.x release
-- Fixed
1 parent 0caff68 commit 2d4c680

File tree

3 files changed

+178
-239
lines changed

3 files changed

+178
-239
lines changed

app/my-dashboard/header-dashboard/header-dashboard.spec.js

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const mockData = require('../../../tests/test-helpers/mock-data')
33

44
/* jshint -W117, -W030 */
55
describe('Header Dashboard Controller', function() {
6-
var userService, profileService, identity
6+
var identity
77
var profile = mockData.getMockProfile()
88
var stats = mockData.getMockStats()
99
var financials = mockData.getMockUserFinancials()
@@ -14,45 +14,14 @@ describe('Header Dashboard Controller', function() {
1414
'$controller',
1515
'$rootScope',
1616
'$q',
17-
'UserService',
18-
'ProfileService',
1917
'Helpers')
2018

21-
userService = UserService
22-
profileService = ProfileService
23-
2419
identity = function() {
2520
return {
2621
handle: 'albertwang',
2722
userId: 123456
2823
}
2924
}
30-
31-
// mock user api
32-
sinon.stub(userService, 'getUserIdentity', function() {
33-
return {
34-
userId: 1234567,
35-
handle: 'ut',
36-
37-
}
38-
})
39-
40-
// mock profile api
41-
sinon.stub(profileService, 'getUserProfile', function(handle) {
42-
var deferred = $q.defer()
43-
deferred.resolve(profile)
44-
return deferred.promise
45-
})
46-
sinon.stub(profileService, 'getUserStats', function(handle) {
47-
var deferred = $q.defer()
48-
deferred.resolve(stats)
49-
return deferred.promise
50-
})
51-
sinon.stub(profileService, 'getUserFinancials', function(handle) {
52-
var deferred = $q.defer()
53-
deferred.resolve(financials)
54-
return deferred.promise
55-
})
5625
})
5726

5827
bard.verifyNoOutstandingHttpRequests()
@@ -61,9 +30,6 @@ describe('Header Dashboard Controller', function() {
6130
var controller = null
6231
beforeEach( function(){
6332
controller = $controller('HeaderDashboardController', {
64-
UserService : userService,
65-
ProfileService: profileService,
66-
userIdentity: identity,
6733
profile: profile
6834
})
6935
$rootScope.$apply()
@@ -75,51 +41,17 @@ describe('Header Dashboard Controller', function() {
7541
})
7642
})
7743

78-
describe('inialization with profile api stats endpoint error', function() {
44+
describe('inialization with null profile', function() {
7945
var controller = null
8046
beforeEach( function(){
81-
profileService.getUserStats.restore()
82-
sinon.stub(profileService, 'getUserStats', function(handle) {
83-
var deferred = $q.defer()
84-
deferred.reject('failed')
85-
return deferred.promise
86-
})
87-
controller = $controller('HeaderDashboardController', {
88-
UserService : userService,
89-
ProfileService: profileService,
90-
userIdentity: identity,
91-
profile: profile
92-
})
93-
$rootScope.$apply()
94-
})
95-
96-
it('variables should be initialized to correct value', function() {
97-
expect(controller.profile).to.exist
98-
expect(controller.profile.handle).to.equal('albertwang')
99-
})
100-
})
101-
102-
describe('inialization with profile api profile endpoint error', function() {
103-
var controller = null
104-
beforeEach( function(){
105-
profileService.getUserProfile.restore()
106-
sinon.stub(profileService, 'getUserProfile', function(handle) {
107-
var deferred = $q.defer()
108-
deferred.reject('failed')
109-
return deferred.promise
110-
})
11147
controller = $controller('HeaderDashboardController', {
112-
UserService : userService,
113-
ProfileService: profileService,
114-
userIdentity: identity,
115-
profile: profileService.getUserProfile()
48+
profile: null
11649
})
11750
$rootScope.$apply()
11851
})
11952

12053
it('variables should be initialized to correct value', function() {
121-
expect(controller.profile.$$state.status).to.equal(2)
122-
expect(controller.profile.$$state.value).to.equal('failed')
54+
expect(controller.profile).to.be.null
12355
})
12456
})
12557

app/services/externalAccounts.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ import _ from 'lodash'
194194
} else {
195195
logger.error('Unsupported social login backend', provider)
196196

197-
$q.reject({
197+
reject({
198198
status: 'failed',
199199
'error': 'Unsupported social login backend \'' + provider + '\''
200200
})

0 commit comments

Comments
 (0)