-
Notifications
You must be signed in to change notification settings - Fork 12
/
watchQuery.ts
48 lines (40 loc) · 1004 Bytes
/
watchQuery.ts
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
import { assert } from 'chai';
import { RxApolloClient } from '../../src/RxApolloClient';
import * as heroes from '../fixtures/heroes';
describe('RxApolloClient.watchQuery', () => {
let client: RxApolloClient;
beforeEach(() => {
client = heroes.mockRxClient().client;
});
it('should get the result', (done) => {
const obs = client.watchQuery({
query: heroes.query,
});
obs.subscribe({
next(result) {
assert.deepEqual(result.data, heroes.data);
done();
},
error() {
done(new Error('should not be called'));
},
});
});
it('should be able to refetch', (done) => {
const obs = client.watchQuery({
query: heroes.query,
});
obs.subscribe({
next() {
//
},
error() {
done(new Error('should not be called'));
},
});
obs.refetch(heroes.variables).then(({data}) => {
assert.deepEqual(data, heroes.dataWithVariables);
done();
});
});
});