Skip to content

Commit

Permalink
feat(PeopleAdapter): add getMe method definition
Browse files Browse the repository at this point in the history
  • Loading branch information
lalli-flores committed Dec 5, 2019
1 parent bc634df commit 0172fd9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
14 changes: 14 additions & 0 deletions src/PeopleAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ export const PersonStatus = {
* @interface
*/
export default class PeopleAdapter extends WebexAdapter {
/**
* Returns an observable that emits person data of the current user.
*
* Current user is be defined by the implementation. For instance,
* to instantiate the SDK, an access token must be given, "me" in that case
* is the owner of the access token for that SDK instance.
*
* @returns {Observable.<Person>}
* @memberof PeopleAdapter
*/
getMe() {
return throwError(new Error('getMe() must be defined in PeopleAdapter'));
}

/**
* Returns an observable that emits person data of the given ID.
*
Expand Down
38 changes: 28 additions & 10 deletions src/PeopleAdapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,35 @@ describe('People Adapter Interface', () => {
peopleAdapter = null;
});

test('getPerson() returns an observable', () => {
expect(isObservable(peopleAdapter.getPerson())).toBeTruthy();
describe('getPerson()', () => {
test('returns an observable', () => {
expect(isObservable(peopleAdapter.getPerson())).toBeTruthy();
});

test('errors because it needs to be defined', (done) => {
peopleAdapter.getPerson('id').subscribe(
() => {},
(error) => {
expect(error.message).toBe('getPerson(ID) must be defined in PeopleAdapter');
done();
}
);
});
});

test('getPerson() errors because it needs to be defined', (done) => {
peopleAdapter.getPerson('id').subscribe(
() => {},
(error) => {
expect(error.message).toBe('getPerson(ID) must be defined in PeopleAdapter');
done();
}
);
describe('getMe()', () => {
test('returns an observable', () => {
expect(isObservable(peopleAdapter.getPerson())).toBeTruthy();
});

test('errors because it needs to be defined', (done) => {
peopleAdapter.getPerson('id').subscribe(
() => {},
(error) => {
expect(error.message).toBe('getPerson(ID) must be defined in PeopleAdapter');
done();
}
);
});
});
});

0 comments on commit 0172fd9

Please sign in to comment.