-
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(ActivitiesAdapter): implement adapter
- Loading branch information
Showing
2 changed files
with
62 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,33 @@ | ||
import {throwError} from 'rxjs'; | ||
|
||
import WebexAdapter from './WebexAdapter'; | ||
|
||
/** | ||
* An activity a person performs in Webex. | ||
* | ||
* @typedef {Object} Activity | ||
* @property {string} ID The activity identifier. | ||
* @property {string} roomID ID of the room where the activity happens. | ||
* @property {string} text Any text the activity may contain. | ||
* @property {string} personID ID of the person performing the activity. | ||
* @property {Date} created Timestamp of the time when the activity happened. | ||
* @property {Boolean} displayAuthor Whether to display author information or not. | ||
*/ | ||
|
||
/** | ||
* This is a base class that defines the interface that maps activity data. | ||
* Developers that want to extend `ActivitiesAdapter` must implement all of its methods, | ||
* adhering to the exact parameters and structure of the returned objects. | ||
*/ | ||
export default class ActivitiesAdapter extends WebexAdapter { | ||
/** | ||
* Returns an observable that emits activity data of the given ID. | ||
* | ||
* @param {string} ID ID of the activity to get. | ||
* @returns {Observable.<Activity>} | ||
* @memberof ActivityAdapter | ||
*/ | ||
getActivity(ID) { | ||
return throwError(new Error('getActivity(ID) must be defined in ActivitiesAdapter')); | ||
} | ||
} |
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,29 @@ | ||
import {isObservable} from 'rxjs'; | ||
|
||
import ActivitiesAdapter from './ActivitiesAdapter'; | ||
|
||
describe('Activities Adapter Interface', () => { | ||
let activitiesAdapter; | ||
|
||
beforeEach(() => { | ||
activitiesAdapter = new ActivitiesAdapter(); | ||
}); | ||
|
||
test('getActivity() returns an observable', () => { | ||
expect(isObservable(activitiesAdapter.getActivity())).toBeTruthy(); | ||
}); | ||
|
||
test('getActivity() errors because it needs to be defined', (done) => { | ||
activitiesAdapter.getActivity('msgID').subscribe( | ||
() => {}, | ||
(error) => { | ||
expect(error.message).toBe('getActivity(ID) must be defined in ActivitiesAdapter'); | ||
done(); | ||
} | ||
); | ||
}); | ||
|
||
afterEach(() => { | ||
activitiesAdapter = null; | ||
}); | ||
}); |