-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1498 from ushahidi/develop
Prepare release select-all fix
- Loading branch information
Showing
4 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,11 +47,15 @@ describe('user profile directive', function () { | |
describe('with a successful backend call', function () { | ||
beforeEach(function () { | ||
spyOn(UserEndpoint, 'update').and.callThrough(); | ||
spyOn(Session, 'setSessionDataEntries').and.callThrough(); | ||
spyOn(Notify, 'apiErrors') | ||
spyOn(Notify, 'notify').and.callThrough(); | ||
}); | ||
|
||
describe('after changed values of user', function () { | ||
beforeEach(function () { | ||
isolateScope.user.realname = 'Changed name'; | ||
isolateScope.user.email = '[email protected]'; | ||
}); | ||
|
||
describe('after calling saveUser', function () { | ||
|
@@ -60,19 +64,54 @@ describe('user profile directive', function () { | |
}); | ||
|
||
it('should call "update" on the UserEndpoint with id=me and the changed user profile values', function () { | ||
expect(UserEndpoint.update).toHaveBeenCalled(); | ||
expect(UserEndpoint.update).toHaveBeenCalledWith( | ||
{id: 'me'}, | ||
jasmine.objectContaining({ | ||
'email': '[email protected]', | ||
'realname': 'Changed name' | ||
} | ||
) | ||
); | ||
expect(isolateScope.user.realname).toBe('Changed name'); | ||
expect(isolateScope.user.email).toBe('[email protected]'); | ||
expect(Notify.notify).toHaveBeenCalledWith('user_profile.update_success'); | ||
expect(Notify.apiErrors).toHaveBeenCalledTimes(0) | ||
expect(Session.setSessionDataEntries).toHaveBeenCalledWith( | ||
{'email': '[email protected]', 'realname': 'Changed name'} | ||
); | ||
}); | ||
|
||
it('should set user to the new data', function () { | ||
expect(isolateScope.user.someField).toBe('addedByServer'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('after changed the password of the user', function () { | ||
beforeEach(function () { | ||
isolateScope.user.password = 'changed'; | ||
}); | ||
|
||
describe('after calling saveUser', function () { | ||
beforeEach(function () { | ||
isolateScope.saveUser(isolateScope.user); | ||
}); | ||
|
||
it('should call "update" on the UserEndpoint with the changed password', function () { | ||
expect(UserEndpoint.update).toHaveBeenCalledWith( | ||
{id: 'me'}, | ||
jasmine.objectContaining({ | ||
'password': 'changed' | ||
} | ||
) | ||
); | ||
expect(Notify.apiErrors).toHaveBeenCalledTimes(0) | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('with an error on the backend call', function () { | ||
|
||
var errorResponse = { | ||
status: 400, | ||
data: { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,8 @@ module.exports = [function () { | |
successCallback({ | ||
realname: 'Changed name', | ||
id: 1, | ||
someField: 'addedByServer' | ||
someField: 'addedByServer', | ||
email: '[email protected]' | ||
}); | ||
} else { | ||
failCallback({ | ||
|