-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(orgs): add OrganizationsAdapter definition
- Loading branch information
1 parent
5691c09
commit 600d54f
Showing
3 changed files
with
63 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
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')); | ||
} | ||
} |
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 |
---|---|---|
@@ -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(); | ||
}, | ||
); | ||
}); | ||
}); | ||
}); |
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