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

Commit 7e34139

Browse files
author
vikasrohit
authored
Merge pull request #921 from appirio-tech/feature/fix_unit_tests
Github issue #919, Few Unit tests failing after angular 1.6.x release
2 parents 0caff68 + 85bb85c commit 7e34139

File tree

3 files changed

+177
-248
lines changed

3 files changed

+177
-248
lines changed

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

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

44
/* jshint -W117, -W030 */
55
describe('Header Dashboard Controller', function() {
6-
var userService, profileService, identity
76
var profile = mockData.getMockProfile()
8-
var stats = mockData.getMockStats()
9-
var financials = mockData.getMockUserFinancials()
107

118
beforeEach(function() {
129
bard.appModule('topcoder')
1310
bard.inject(this,
1411
'$controller',
1512
'$rootScope',
1613
'$q',
17-
'UserService',
18-
'ProfileService',
1914
'Helpers')
20-
21-
userService = UserService
22-
profileService = ProfileService
23-
24-
identity = function() {
25-
return {
26-
handle: 'albertwang',
27-
userId: 123456
28-
}
29-
}
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-
})
5615
})
5716

5817
bard.verifyNoOutstandingHttpRequests()
@@ -61,33 +20,6 @@ describe('Header Dashboard Controller', function() {
6120
var controller = null
6221
beforeEach( function(){
6322
controller = $controller('HeaderDashboardController', {
64-
UserService : userService,
65-
ProfileService: profileService,
66-
userIdentity: identity,
67-
profile: profile
68-
})
69-
$rootScope.$apply()
70-
})
71-
72-
it('variables should be initialized to correct value', function() {
73-
expect(controller.profile).to.exist
74-
expect(controller.profile.handle).to.equal('albertwang')
75-
})
76-
})
77-
78-
describe('inialization with profile api stats endpoint error', function() {
79-
var controller = null
80-
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,
9123
profile: profile
9224
})
9325
$rootScope.$apply()
@@ -99,27 +31,17 @@ describe('Header Dashboard Controller', function() {
9931
})
10032
})
10133

102-
describe('inialization with profile api profile endpoint error', function() {
34+
describe('inialization with null profile', function() {
10335
var controller = null
10436
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-
})
11137
controller = $controller('HeaderDashboardController', {
112-
UserService : userService,
113-
ProfileService: profileService,
114-
userIdentity: identity,
115-
profile: profileService.getUserProfile()
38+
profile: null
11639
})
11740
$rootScope.$apply()
11841
})
11942

12043
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')
44+
expect(controller.profile).to.be.null
12345
})
12446
})
12547

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)