This repository has been archived by the owner on May 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
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 #1194 from 18F/js-fix-invite-space-user-list
fix space user from automatically being populated upon invite
- Loading branch information
Showing
5 changed files
with
119 additions
and
23 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
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 |
---|---|---|
|
@@ -281,7 +281,7 @@ describe('UserStore', function () { | |
}); | ||
|
||
it('should emit a change', function() { | ||
expect(UserStore.emitChange).toHaveBeenCalledTwice(); | ||
expect(UserStore.emitChange).toHaveBeenCalledOnce(); | ||
}); | ||
|
||
it('should add the user to the org through an empty role list', function() { | ||
|
@@ -326,6 +326,67 @@ describe('UserStore', function () { | |
}); | ||
}); | ||
|
||
describe('on space user associated', () => { | ||
const userGuid = 'user-543'; | ||
const spaceGuid = 'space-abc'; | ||
let spaceUsers; | ||
|
||
beforeEach(() => { | ||
const user = { | ||
guid: userGuid, | ||
username: '[email protected]' | ||
}; | ||
spaceUsers = [user, {userGuid: 'wrong-udid'}, {userGuid: 'wrong-udid-2'}]; | ||
sandbox.spy(UserStore, 'emitChange'); | ||
userActions.createdUserAndAssociated(userGuid, spaceGuid, spaceUsers, 'space_users'); | ||
}); | ||
|
||
it('should emit a change', function() { | ||
expect(UserStore.emitChange).toHaveBeenCalledOnce(); | ||
}); | ||
|
||
it('should add the user to the space through an empty role list', function() { | ||
const actualUser = UserStore.get(userGuid); | ||
expect(actualUser).toBeDefined(); | ||
expect(actualUser.space_roles).toBeDefined(); | ||
expect(actualUser.space_roles[spaceGuid]).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('on space user association received', function() { | ||
it('should emit a change event if data changed', function() { | ||
var spy = sandbox.spy(UserStore, 'emitChange'); | ||
const userGuid = "fake-user-guid"; | ||
const entityGuid = "fake-space-guid"; | ||
const entityUsers = [ | ||
{userGuid: userGuid}, | ||
{userGuid: "fake-user-guid-2"}, | ||
{userGuid: "fake-user-guid-3"} | ||
]; | ||
|
||
userActions.createdUserAndAssociated(userGuid, entityGuid, entityUsers); | ||
|
||
expect(spy).toHaveBeenCalledOnce(); | ||
}); | ||
|
||
it('should merge and update space with new users', function() { | ||
const existingUser = { guid: 'wpqoifesadkzcvn', name: 'Michael' }; | ||
const newUser = { guid: 'dkzcvwpqoifesan' }; | ||
|
||
UserStore.push(existingUser); | ||
expect(UserStore.get('wpqoifesadkzcvn')).toEqual(existingUser); | ||
|
||
AppDispatcher.handleViewAction({ | ||
type: userActionTypes.USER_SPACE_ASSOCIATED, | ||
user: { guid: 'blah' }, | ||
spaceGuid: 'adsfa' | ||
}); | ||
let actual = UserStore.get('wpqoifesadkzcvn'); | ||
let expected = Object.assign({}, existingUser, newUser); | ||
expect(actual).not.toEqual(expected); | ||
}); | ||
}); | ||
|
||
describe('on user role toggle error', () => { | ||
it('updates the error and saving properties of the user store', () => { | ||
const message = 'oh no!'; | ||
|