1
- import { createServer , Server } from 'node:http' ;
2
- import { AddressInfo } from 'node:net' ;
3
1
import { setTimeout as setTimeout$ } from 'node:timers/promises' ;
4
2
import { ExecutionResult } from 'graphql' ;
5
3
import { createSchema , createYoga } from 'graphql-yoga' ;
@@ -9,7 +7,6 @@ import { Client, createClient } from '@urql/core';
9
7
10
8
describe ( 'URQL Yoga Exchange' , ( ) => {
11
9
const endpoint = '/graphql' ;
12
- const hostname = '127.0.0.1' ;
13
10
const yoga = createYoga ( {
14
11
graphqlEndpoint : endpoint ,
15
12
logging : false ,
@@ -29,10 +26,10 @@ describe('URQL Yoga Exchange', () => {
29
26
` ,
30
27
resolvers : {
31
28
Query : {
32
- hello : ( ) => 'Hello Urql Client!' ,
29
+ hello : async ( ) => 'Hello Urql Client!' ,
33
30
} ,
34
31
Mutation : {
35
- readFile : ( _ , args : { file : File } ) => args . file . text ( ) ,
32
+ readFile : async ( _ , args : { file : File } ) => args . file . text ( ) ,
36
33
} ,
37
34
Subscription : {
38
35
time : {
@@ -42,34 +39,25 @@ describe('URQL Yoga Exchange', () => {
42
39
yield new Date ( ) . toISOString ( ) ;
43
40
}
44
41
} ,
45
- resolve : str => str ,
42
+ resolve : async str => str ,
46
43
} ,
47
44
} ,
48
45
} ,
49
46
} ) ,
50
47
} ) ;
51
48
52
- let server : Server ;
53
- let url : string ;
54
49
let client : Client ;
55
50
56
51
beforeAll ( async ( ) => {
57
- server = createServer ( yoga ) ;
58
- await new Promise < void > ( resolve => server . listen ( 0 , hostname , resolve ) ) ;
59
- const port = ( server . address ( ) as AddressInfo ) . port ;
60
- url = `http://${ hostname } :${ port } ${ endpoint } ` ;
61
52
client = createClient ( {
62
- url,
53
+ url : 'http://localhost:4000/graphql' ,
63
54
exchanges : [
64
55
yogaExchange ( {
65
56
fetch : yoga . fetch as WindowOrWorkerGlobalScope [ 'fetch' ] ,
66
57
} ) ,
67
58
] ,
68
59
} ) ;
69
60
} ) ;
70
- afterAll ( done => {
71
- server . close ( done ) ;
72
- } ) ;
73
61
it ( 'should handle queries correctly' , async ( ) => {
74
62
const result = await client
75
63
. query (
@@ -127,7 +115,7 @@ describe('URQL Yoga Exchange', () => {
127
115
expect ( new Date ( value ! ) . getFullYear ( ) ) . toBe ( now . getFullYear ( ) ) ;
128
116
}
129
117
} ) ;
130
- it . skip ( 'should handle file uploads correctly' , async ( ) => {
118
+ it ( 'should handle file uploads correctly' , async ( ) => {
131
119
const query = /* GraphQL */ `
132
120
mutation readFile($file: File!) {
133
121
readFile(file: $file)
0 commit comments