-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,80 +6,104 @@ | |
*/ | ||
|
||
import { userProfiles, userProfilesMap } from '../../containers/user_profiles/api.mock'; | ||
import { convertToUserInfo } from './user_converter'; | ||
import { convertToCaseUserWithProfileInfo, convertToUserInfo } from './user_converter'; | ||
|
||
describe('convertToUserInfo', () => { | ||
it('returns undefined when the username is an empty string and the profile uid is not defined', () => { | ||
expect(convertToUserInfo({ username: '', email: null, fullName: null })).toBeUndefined(); | ||
}); | ||
describe('user_converter', () => { | ||
describe('convertToUserInfo', () => { | ||
it('returns undefined when the username is an empty string and the profile uid is not defined', () => { | ||
expect(convertToUserInfo({ username: '', email: null, fullName: null })).toBeUndefined(); | ||
}); | ||
|
||
it('returns a key of 123 and empty user info when the username is an empty string and the profile uid is not found', () => { | ||
expect( | ||
convertToUserInfo({ username: '', profileUid: '123', email: null, fullName: null }) | ||
).toEqual({ | ||
key: '123', | ||
userInfo: {}, | ||
it('returns a key of 123 and empty user info when the username is an empty string and the profile uid is not found', () => { | ||
expect( | ||
convertToUserInfo({ username: '', profileUid: '123', email: null, fullName: null }) | ||
).toEqual({ | ||
key: '123', | ||
userInfo: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
it('returns the profile uid as the key and full profile when the profile uid is found', () => { | ||
expect( | ||
convertToUserInfo( | ||
{ profileUid: userProfiles[0].uid, email: null, fullName: null, username: null }, | ||
userProfilesMap | ||
) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"key": "u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0", | ||
"userInfo": Object { | ||
"data": Object {}, | ||
"enabled": true, | ||
"uid": "u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0", | ||
"user": Object { | ||
"email": "[email protected]", | ||
"full_name": "Damaged Raccoon", | ||
"username": "damaged_raccoon", | ||
}, | ||
}, | ||
} | ||
`); | ||
}); | ||
it('returns the profile uid as the key and full profile when the profile uid is found', () => { | ||
expect( | ||
convertToUserInfo( | ||
{ profileUid: userProfiles[0].uid, email: null, fullName: null, username: null }, | ||
userProfilesMap | ||
) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"key": "u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0", | ||
"userInfo": Object { | ||
"data": Object {}, | ||
"enabled": true, | ||
"uid": "u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0", | ||
"user": Object { | ||
"email": "[email protected]", | ||
"full_name": "Damaged Raccoon", | ||
"username": "damaged_raccoon", | ||
}, | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it('returns the username as the key and the user info using the existing elastic user information', () => { | ||
expect(convertToUserInfo({ username: 'sam', fullName: 'Sam Smith', email: '[email protected]' })) | ||
.toMatchInlineSnapshot(` | ||
Object { | ||
"key": "sam", | ||
"userInfo": Object { | ||
"user": Object { | ||
"email": "[email protected]", | ||
"full_name": "Sam Smith", | ||
"username": "sam", | ||
}, | ||
}, | ||
} | ||
`); | ||
it('returns the username as the key and the user info using the existing elastic user information', () => { | ||
expect(convertToUserInfo({ username: 'sam', fullName: 'Sam Smith', email: '[email protected]' })) | ||
.toMatchInlineSnapshot(` | ||
Object { | ||
"key": "sam", | ||
"userInfo": Object { | ||
"user": Object { | ||
"email": "[email protected]", | ||
"full_name": "Sam Smith", | ||
"username": "sam", | ||
}, | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it('returns the username as the key and the user info using the existing elastic user information when the profile uid is not found', () => { | ||
expect( | ||
convertToUserInfo({ | ||
username: 'sam', | ||
fullName: 'Sam Smith', | ||
email: '[email protected]', | ||
profileUid: '123', | ||
}) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"key": "sam", | ||
"userInfo": Object { | ||
"user": Object { | ||
"email": "[email protected]", | ||
"full_name": "Sam Smith", | ||
"username": "sam", | ||
}, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
it('returns the username as the key and the user info using the existing elastic user information when the profile uid is not found', () => { | ||
expect( | ||
convertToUserInfo({ | ||
username: 'sam', | ||
fullName: 'Sam Smith', | ||
email: '[email protected]', | ||
profileUid: '123', | ||
}) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"key": "sam", | ||
"userInfo": Object { | ||
describe('convertToCaseUserWithProfileInfo', () => { | ||
it('converts a CaseUse to a CaseUserWithProfileInfo correctly', () => { | ||
expect( | ||
convertToCaseUserWithProfileInfo({ | ||
username: 'test', | ||
email: '[email protected]', | ||
fullName: 'Test', | ||
profileUid: 'test-id', | ||
}) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"uid": "test-id", | ||
"user": Object { | ||
"email": "[email protected]", | ||
"full_name": "Sam Smith", | ||
"username": "sam", | ||
"email": "[email protected]", | ||
"full_name": "Test", | ||
"username": "test", | ||
}, | ||
}, | ||
} | ||
`); | ||
} | ||
`); | ||
}); | ||
}); | ||
}); |
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