Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 53bfec8

Browse files
author
vikasrohit
committedMay 11, 2016
AS#131482348128949, Refactor Mailchimp API wrapper to be generic user preferences service
-- Fixed new service reference in tests
1 parent a6b7105 commit 53bfec8

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed
 

‎app/skill-picker/skill-picker.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('Skill Picker Controller', function() {
5353
})
5454

5555
userPrefSvc = UserPreferencesService
56-
sinon.stub(userPrefSvc, 'getMemberSubscription', function(user) {
56+
sinon.stub(userPrefSvc, 'getEmailPreferences', function(user) {
5757
var deferred = $q.defer()
5858
if (user.userId === 10336829) {
5959
deferred.resolve()
@@ -65,7 +65,7 @@ describe('Skill Picker Controller', function() {
6565
}
6666
return deferred.promise
6767
})
68-
sinon.stub(userPrefSvc, 'addSubscription', function(user) {
68+
sinon.stub(userPrefSvc, 'saveEmailPreferences', function(user) {
6969
var deferred = $q.defer()
7070
if (user.userId === 10336829) {
7171
deferred.resolve()
@@ -140,17 +140,17 @@ describe('Skill Picker Controller', function() {
140140

141141
it('should call mailchimp service to add subscription', function() {
142142
expect(vm).to.exist
143-
// getMemberSubscription should always be called
144-
expect(userPrefSvc.getMemberSubscription).to.be.calledOnce
145-
// addSubscription should be called once if not subscribed
146-
// getMemberSubscription service mock returns null for mockProfile.userId
147-
expect(userPrefSvc.addSubscription).to.be.calledOnce
143+
// getEmailPreferences should always be called
144+
expect(userPrefSvc.getEmailPreferences).to.be.calledOnce
145+
// saveEmailPreferences should be called once if not subscribed
146+
// getEmailPreferences service mock returns null for mockProfile.userId
147+
expect(userPrefSvc.saveEmailPreferences).to.be.calledOnce
148148
})
149149

150150
it('should not call mailchimp service to add subscription', function() {
151-
// reset getMemberSubscription, addSubscription spy's called count
152-
userPrefSvc.getMemberSubscription.reset()
153-
userPrefSvc.addSubscription.reset()
151+
// reset getEmailPreferences, saveEmailPreferences spy's called count
152+
userPrefSvc.getEmailPreferences.reset()
153+
userPrefSvc.saveEmailPreferences.reset()
154154
var scope = $rootScope.$new()
155155

156156
var profile = angular.copy(mockProfile)
@@ -164,11 +164,11 @@ describe('Skill Picker Controller', function() {
164164
})
165165
$rootScope.$digest()
166166
expect(vm).to.exist
167-
// getMemberSubscription should always be called
168-
expect(userPrefSvc.getMemberSubscription).to.be.calledOnce
169-
// addSubscription should not be called if already subscribed
170-
// getMemberSubscription service mock returns valid object for userId 12345
171-
expect(userPrefSvc.addSubscription).not.to.be.called
167+
// getEmailPreferences should always be called
168+
expect(userPrefSvc.getEmailPreferences).to.be.calledOnce
169+
// saveEmailPreferences should not be called if already subscribed
170+
// getEmailPreferences service mock returns valid object for userId 12345
171+
expect(userPrefSvc.saveEmailPreferences).not.to.be.called
172172
})
173173

174174
it('should add skill ', function() {

0 commit comments

Comments
 (0)
This repository has been archived.