forked from webex/components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivitiesJSONAdapter.test.js
53 lines (44 loc) · 1.4 KB
/
ActivitiesJSONAdapter.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {isObservable} from 'rxjs';
import activities from '../data/activities';
import ActivitiesJSONAdapter from './ActivitiesJSONAdapter';
describe('Activities JSON Adapter Interface', () => {
let activityID;
let activitiesJSONAdapter;
beforeEach(() => {
[activityID] = Object.keys(activities);
activitiesJSONAdapter = new ActivitiesJSONAdapter(activities);
});
afterEach(() => {
activityID = null;
activitiesJSONAdapter = null;
});
test('getActivity() returns an observable', () => {
expect(isObservable(activitiesJSONAdapter.getActivity())).toBeTruthy();
});
test('getActivity() returns an activity', (done) => {
activitiesJSONAdapter.getActivity(activityID).subscribe((data) => {
expect(data).toEqual(activities[activityID]);
done();
});
});
test('getActivity() throws a proper error message when activity doesn\'t exist', (done) => {
const wrongActivityID = 'wrongActivityID';
activitiesJSONAdapter.getActivity(wrongActivityID).subscribe(
() => {},
(error) => {
expect(error.message).toBe(`Could not find activity with ID "${wrongActivityID}"`);
done();
},
);
});
test('getActivity() completes the observable', (done) => {
activitiesJSONAdapter.getActivity(activityID).subscribe(
() => {},
() => {},
() => {
expect(true).toBeTruthy();
done();
},
);
});
});