@@ -21,6 +21,90 @@ describe('getDiff', () => {
21
21
expect ( result ) . toBeUndefined ( ) ;
22
22
} ) ;
23
23
24
+ it ( 'fetches remote schemas with headers' , async ( ) => {
25
+ nock ( testRemoteSchemaLocation )
26
+ . matchHeader ( 'test' , 'test' )
27
+ . post ( '' , JSON . stringify ( { query : introspectionQuery } ) )
28
+ . twice ( )
29
+ . reply ( 200 , introspectionResponse ) ;
30
+
31
+ const result = await getDiff (
32
+ testRemoteSchemaLocation ,
33
+ testRemoteSchemaLocation ,
34
+ {
35
+ headers : {
36
+ Test : 'test'
37
+ }
38
+ }
39
+ ) ;
40
+ expect ( result ) . toBeUndefined ( ) ;
41
+ } ) ;
42
+
43
+ it ( 'fetches remote schemas with left and right schema headers' , async ( ) => {
44
+ const testRemoteRightSchemaLocation = 'http://testRight/graphql' ;
45
+ nock ( testRemoteSchemaLocation )
46
+ . matchHeader ( 'test' , 'left' )
47
+ . post ( '' , JSON . stringify ( { query : introspectionQuery } ) )
48
+ . reply ( 200 , introspectionResponse ) ;
49
+ nock ( testRemoteRightSchemaLocation )
50
+ . matchHeader ( 'test' , 'right' )
51
+ . post ( '' , JSON . stringify ( { query : introspectionQuery } ) )
52
+ . reply ( 200 , introspectionResponse ) ;
53
+
54
+ const result = await getDiff (
55
+ testRemoteSchemaLocation ,
56
+ testRemoteRightSchemaLocation ,
57
+ {
58
+ leftSchema : {
59
+ headers : {
60
+ Test : 'left'
61
+ }
62
+ } ,
63
+ rightSchema : {
64
+ headers : {
65
+ Test : 'right'
66
+ }
67
+ }
68
+ }
69
+ ) ;
70
+ expect ( result ) . toBeUndefined ( ) ;
71
+ } ) ;
72
+
73
+ it ( 'fetches remote schemas with merged schema headers' , async ( ) => {
74
+ const testRemoteRightSchemaLocation = 'http://testRight/graphql' ;
75
+ nock ( testRemoteSchemaLocation )
76
+ . matchHeader ( 'global' , 'merged' )
77
+ . matchHeader ( 'test' , 'left' )
78
+ . post ( '' , JSON . stringify ( { query : introspectionQuery } ) )
79
+ . reply ( 200 , introspectionResponse ) ;
80
+ nock ( testRemoteRightSchemaLocation )
81
+ . matchHeader ( 'global' , 'merged' )
82
+ . matchHeader ( 'test' , 'right' )
83
+ . post ( '' , JSON . stringify ( { query : introspectionQuery } ) )
84
+ . reply ( 200 , introspectionResponse ) ;
85
+
86
+ const result = await getDiff (
87
+ testRemoteSchemaLocation ,
88
+ testRemoteRightSchemaLocation ,
89
+ {
90
+ headers : {
91
+ Global : 'merged' ,
92
+ } ,
93
+ leftSchema : {
94
+ headers : {
95
+ Test : 'left'
96
+ }
97
+ } ,
98
+ rightSchema : {
99
+ headers : {
100
+ Test : 'right'
101
+ }
102
+ }
103
+ }
104
+ ) ;
105
+ expect ( result ) . toBeUndefined ( ) ;
106
+ } ) ;
107
+
24
108
it ( 'throws error on status codes other than 200' , ( ) => {
25
109
nock ( testRemoteSchemaLocation )
26
110
. post ( '' , JSON . stringify ( { query : introspectionQuery } ) )
0 commit comments