-
-
Save mohuk/fac9e35237b283813474 to your computer and use it in GitHub Desktop.
userProfileControllerTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
ddescribe('Controller: userProfile', function(){ | |
beforeEach(module('SAPortal')); | |
beforeEach(module('app.dashboard')); | |
beforeEach(module('SAPortal.mocks')); | |
beforeEach(inject(init)); | |
var _dataservice, _q, _userProfileData, _rootScope, _userProfile, _userProfileDeferred; | |
function init($injector, $controller){ | |
_userProfileData = $injector.get('userProfileData'); | |
_rootScope = $injector.get('$rootScope').$new(); | |
_q = $injector.get('$q'); | |
_dataservice = jasmine.createSpyObj('_dataservice', ['getUserProfile', 'getUserPermissions']); | |
_dataservice.getUserProfile.and.callFake(userProfilePromise); | |
function userProfilePromise(){ | |
_userProfileDeferred = _q.defer(); | |
return _userProfileDeferred.promise; | |
} | |
_userProfile = $controller('userProfile', { | |
dataservice: _dataservice | |
}); | |
} | |
it('should set user profile on controller', setUserProfile); | |
function setUserProfile(){ | |
_userProfileDeferred.resolve(_userProfileData.userProfile); | |
_rootScope.$digest(); | |
expect(_userProfile.name).toBe("Johnny Joker"); | |
expect(_userProfile.age).toBe(27); | |
expect(_userProfile.email).toBe("johnnyjoker@pokerface.com"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment