-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(PeopleSdkAdapter): add search people method
- Loading branch information
1 parent
acb75b6
commit fec1465
Showing
2 changed files
with
98 additions
and
0 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 |
---|---|---|
|
@@ -7,11 +7,13 @@ describe('People SDK Adapter', () => { | |
let mockSDK; | ||
let peopleSDKAdapter; | ||
let personID; | ||
let query; | ||
|
||
beforeEach(() => { | ||
mockSDK = createMockSDK(); | ||
peopleSDKAdapter = new PeopleSDKAdapter(mockSDK); | ||
personID = 'personID'; | ||
query = 'query'; | ||
}); | ||
|
||
describe('getMe()', () => { | ||
|
@@ -119,6 +121,58 @@ describe('People SDK Adapter', () => { | |
}); | ||
}); | ||
|
||
describe('searchPeople', () => { | ||
test('returns an observable', () => { | ||
expect(isObservable(peopleSDKAdapter.searchPeople(query))).toBeTruthy(); | ||
}); | ||
|
||
test('emits persons list on subscription', (done) => { | ||
mockSDK.people.list = jest.fn(() => Promise.resolve({ | ||
items: [ | ||
{ | ||
id: 'personIDCurrentUser', | ||
emails: ['[email protected]'], | ||
displayName: 'Webex Components', | ||
firstName: 'Webex', | ||
lastName: 'Components', | ||
nickName: 'Webex', | ||
avatar: 'avatar', | ||
orgId: 'orgID', | ||
status: 'active', | ||
}, | ||
], | ||
})); | ||
|
||
peopleSDKAdapter.searchPeople(query).subscribe((peopleList) => { | ||
expect(peopleList).toEqual([{ | ||
ID: 'personIDCurrentUser', | ||
emails: ['[email protected]'], | ||
displayName: 'Webex Components', | ||
firstName: 'Webex', | ||
lastName: 'Components', | ||
nickName: 'Webex', | ||
avatar: 'avatar', | ||
orgID: 'orgID', | ||
status: 'active', | ||
}]); | ||
}); | ||
done(); | ||
}); | ||
|
||
test('emits an error if the SDK fails to fetch the person list', (done) => { | ||
const errorMsg = 'error fetching person list'; | ||
|
||
mockSDK.people.list = jest.fn(() => Promise.reject(new Error(errorMsg))); | ||
peopleSDKAdapter.searchPeople(query).subscribe( | ||
() => {}, | ||
(error) => { | ||
expect(error.message).toBe(errorMsg); | ||
done(); | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
mockSDK = null; | ||
peopleSDKAdapter = null; | ||
|