Skip to content

Commit 4006b47

Browse files
committed
fix(ActivityAdapter): replace activity with activities
1 parent 8948c3d commit 4006b47

File tree

4 files changed

+61
-60
lines changed

4 files changed

+61
-60
lines changed

src/adapters/ActivitiesAdapter.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {throwError} from 'rxjs';
2+
3+
import WebexAdapter from './WebexAdapter';
4+
5+
/**
6+
* This is a base class that defines the interface that maps activity data.
7+
* Developers that want to extend `ActivitiesAdapter` must implement all of its methods,
8+
* adhering to the exact parameters and structure of the returned objects.
9+
*/
10+
export default class ActivitiesAdapter extends WebexAdapter {
11+
/**
12+
* An activity a person performs in Webex.
13+
*
14+
* @typedef {Object} Activity
15+
* @property {string} ID The activity identifier.
16+
* @property {string} roomID ID of the room where the activity happens.
17+
* @property {string} text Any text the activity may contain.
18+
* @property {string} personID ID of the person performing the activity.
19+
* @property {Date} created Timestamp of the time when the activity happened.
20+
* @property {Boolean} displayAuthor Whether to display author information or not.
21+
*/
22+
23+
/**
24+
* Returns an observable that emits activity data of the given ID.
25+
*
26+
* @param {string} ID ID of the activity to get.
27+
* @returns {Observable.<Activity>}
28+
* @memberof ActivityAdapter
29+
*/
30+
// eslint-disable-next-line no-unused-vars
31+
getActivity(ID) {
32+
return throwError(new Error('getActivity(ID) must be defined in ActivitiesAdapter'));
33+
}
34+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import ActivitiesAdapter from './ActivitiesAdapter';
2+
3+
describe('Activities Adapter Interface', () => {
4+
let activitiesAdapter;
5+
6+
beforeEach(() => {
7+
activitiesAdapter = new ActivitiesAdapter();
8+
});
9+
10+
test('getActivity() returns an observable', () => {
11+
expect(rxjs.isObservable(activitiesAdapter.getActivity())).toBeTruthy();
12+
});
13+
14+
test('getActivity() throws a proper error message', (done) => {
15+
activitiesAdapter.getActivity('msgID').subscribe(
16+
() => {},
17+
(error) => {
18+
expect(error.message).toBe('getActivity(ID) must be defined in ActivitiesAdapter');
19+
done();
20+
}
21+
);
22+
});
23+
24+
afterEach(() => {
25+
activitiesAdapter = null;
26+
});
27+
});

src/adapters/ActivityAdapter.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/adapters/ActivityAdapter.test.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)