@@ -13,54 +13,7 @@ function mockFetch(data: unknown[] = []) {
1313 } ) ;
1414}
1515
16- function mockMutationFetch ( mutationKey : string ) {
17- return vi . fn ( ) . mockResolvedValue ( {
18- ok : true ,
19- status : 200 ,
20- json : ( ) =>
21- Promise . resolve ( {
22- data : {
23- [ mutationKey ] : { workdayID : { id : '1' , type : 'Thing' } , descriptor : 'T' } ,
24- } ,
25- } ) ,
26- } ) ;
27- }
28-
2916describe ( 'GraphQLResolver' , ( ) => {
30- describe ( 'create' , ( ) => {
31- describe ( 'when creating a record' , ( ) => {
32- it ( 'uses the correct input type name in the mutation' , async ( ) => {
33- globalThis . fetch = mockMutationFetch ( 'app_ns1_createThing' ) ;
34-
35- await new GraphQLResolver ( 'app_ns1' , { Thing : SCHEMA } , ENDPOINT ) . create ( 'Thing' , {
36- descriptor : 'T' ,
37- } ) ;
38-
39- const body = JSON . parse (
40- ( globalThis . fetch as ReturnType < typeof vi . fn > ) . mock . calls [ 0 ] [ 1 ] . body as string
41- ) ;
42- expect ( body . query ) . toContain ( '$input: App_ns1_ThingsSummary_CreateInput!' ) ;
43- } ) ;
44- } ) ;
45- } ) ;
46-
47- describe ( 'update' , ( ) => {
48- describe ( 'when updating a record' , ( ) => {
49- it ( 'uses the correct input type name in the mutation' , async ( ) => {
50- globalThis . fetch = mockMutationFetch ( 'app_ns1_updateThing' ) ;
51-
52- await new GraphQLResolver ( 'app_ns1' , { Thing : SCHEMA } , ENDPOINT ) . update ( 'Thing' , '1' , {
53- descriptor : 'T' ,
54- } ) ;
55-
56- const body = JSON . parse (
57- ( globalThis . fetch as ReturnType < typeof vi . fn > ) . mock . calls [ 0 ] [ 1 ] . body as string
58- ) ;
59- expect ( body . query ) . toContain ( '$input: App_ns1_ThingsSummary_UpdateInput!' ) ;
60- } ) ;
61- } ) ;
62- } ) ;
63-
6417 describe ( 'when constructed with an explicit endpoint' , ( ) => {
6518 it ( 'sends requests to that endpoint' , async ( ) => {
6619 globalThis . fetch = mockFetch ( ) ;
0 commit comments