-
Notifications
You must be signed in to change notification settings - Fork 559
/
pothos.spec.ts
43 lines (32 loc) 路 923 Bytes
/
pothos.spec.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
import { yoga } from '../src/yoga';
describe('pothos example integration', () => {
it('should query', async () => {
const response = await yoga.fetch('http://yoga/graphql?query={hello}');
expect(response.status).toBe(200);
expect(await response.text()).toMatchInlineSnapshot(`"{"data":{"hello":"world"}}"`);
});
it('should subscribe', async () => {
const response = await yoga.fetch('http://yoga/graphql?query=subscription{greetings}', {
headers: {
accept: 'text/event-stream',
},
});
expect(response.status).toBe(200);
expect(await response.text()).toMatchInlineSnapshot(`
":
event: next
data: {"data":{"greetings":"Hi"}}
event: next
data: {"data":{"greetings":"Bonjour"}}
event: next
data: {"data":{"greetings":"Hola"}}
event: next
data: {"data":{"greetings":"Ciao"}}
event: next
data: {"data":{"greetings":"Zdravo"}}
event: complete
data:
"
`);
});
});