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

Github issue #919, Few Unit tests failing after angular 1.6.x release #921

Merged
merged 2 commits into from
Jan 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 3 additions & 81 deletions app/my-dashboard/header-dashboard/header-dashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,15 @@ const mockData = require('../../../tests/test-helpers/mock-data')

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

beforeEach(function() {
bard.appModule('topcoder')
bard.inject(this,
'$controller',
'$rootScope',
'$q',
'UserService',
'ProfileService',
'Helpers')

userService = UserService
profileService = ProfileService

identity = function() {
return {
handle: 'albertwang',
userId: 123456
}
}

// mock user api
sinon.stub(userService, 'getUserIdentity', function() {
return {
userId: 1234567,
handle: 'ut',
email: '[email protected]'
}
})

// mock profile api
sinon.stub(profileService, 'getUserProfile', function(handle) {
var deferred = $q.defer()
deferred.resolve(profile)
return deferred.promise
})
sinon.stub(profileService, 'getUserStats', function(handle) {
var deferred = $q.defer()
deferred.resolve(stats)
return deferred.promise
})
sinon.stub(profileService, 'getUserFinancials', function(handle) {
var deferred = $q.defer()
deferred.resolve(financials)
return deferred.promise
})
})

bard.verifyNoOutstandingHttpRequests()
Expand All @@ -61,33 +20,6 @@ describe('Header Dashboard Controller', function() {
var controller = null
beforeEach( function(){
controller = $controller('HeaderDashboardController', {
UserService : userService,
ProfileService: profileService,
userIdentity: identity,
profile: profile
})
$rootScope.$apply()
})

it('variables should be initialized to correct value', function() {
expect(controller.profile).to.exist
expect(controller.profile.handle).to.equal('albertwang')
})
})

describe('inialization with profile api stats endpoint error', function() {
var controller = null
beforeEach( function(){
profileService.getUserStats.restore()
sinon.stub(profileService, 'getUserStats', function(handle) {
var deferred = $q.defer()
deferred.reject('failed')
return deferred.promise
})
controller = $controller('HeaderDashboardController', {
UserService : userService,
ProfileService: profileService,
userIdentity: identity,
profile: profile
})
$rootScope.$apply()
Expand All @@ -99,27 +31,17 @@ describe('Header Dashboard Controller', function() {
})
})

describe('inialization with profile api profile endpoint error', function() {
describe('inialization with null profile', function() {
var controller = null
beforeEach( function(){
profileService.getUserProfile.restore()
sinon.stub(profileService, 'getUserProfile', function(handle) {
var deferred = $q.defer()
deferred.reject('failed')
return deferred.promise
})
controller = $controller('HeaderDashboardController', {
UserService : userService,
ProfileService: profileService,
userIdentity: identity,
profile: profileService.getUserProfile()
profile: null
})
$rootScope.$apply()
})

it('variables should be initialized to correct value', function() {
expect(controller.profile.$$state.status).to.equal(2)
expect(controller.profile.$$state.value).to.equal('failed')
expect(controller.profile).to.be.null
})
})

Expand Down
2 changes: 1 addition & 1 deletion app/services/externalAccounts.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ import _ from 'lodash'
} else {
logger.error('Unsupported social login backend', provider)

$q.reject({
reject({
status: 'failed',
'error': 'Unsupported social login backend \'' + provider + '\''
})
Expand Down
Loading