Skip to content

Commit

Permalink
feat(orgs): add OrganizationsAdapter definition
Browse files Browse the repository at this point in the history
  • Loading branch information
lalli-flores committed Mar 24, 2021
1 parent 5691c09 commit 600d54f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/OrganizationsAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {throwError} from 'rxjs';

import WebexAdapter from './WebexAdapter';

/**
* A set of people in Webex.
*
* @typedef {object} Organization
* @property {string} ID The organization identifier
* @property {string} name The display name of the organization
*/

/**
* This is a base class that defines the interface that maps organization data.
* Developers that want to extend `OrganizationsAdapter` must implement all of its methods,
* adhering to the exact parameters and structure of the returned objects.
*
* @interface
*/
export default class OrganizationsAdapter extends WebexAdapter {
/**
* Returns an observable that emits organization data of the given ID.
*
* @param {string} ID ID of organization to get
* @returns {external:Observable.<Organization>} Observable stream that emits organization data
* @memberof OrganizationsAdapter
*/
getOrg(ID) {
return throwError(new Error('getOrg(ID) must be defined in OrganizationsAdapter'));
}
}
31 changes: 31 additions & 0 deletions src/OrganizationsAdapter.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {isObservable} from 'rxjs';

import OrganizationsAdapter from './OrganizationsAdapter';

describe('Organizations Adapter Interface', () => {
let orgsAdapter;

beforeEach(() => {
orgsAdapter = new OrganizationsAdapter();
});

afterEach(() => {
orgsAdapter = null;
});

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

test('errors because it needs to be defined', (done) => {
orgsAdapter.getOrg('msgID').subscribe(
() => { },
(error) => {
expect(error.message).toBe('getOrg(ID) must be defined in OrganizationsAdapter');
done();
},
);
});
});
});
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export {default as WebexAdapter} from './WebexAdapter';
export {default as ActivitiesAdapter} from './ActivitiesAdapter';
export {default as MeetingsAdapter, MeetingControlState} from './MeetingsAdapter';
export {default as MembershipsAdapter, DestinationType} from './MembershipsAdapter';
export {default as OrganizationsAdapter} from './OrganizationsAdapter';
export {default as PeopleAdapter, PersonStatus} from './PeopleAdapter';
export {default as RoomsAdapter, RoomType} from './RoomsAdapter';

0 comments on commit 600d54f

Please sign in to comment.