1- const { assert} = require ( ' console' )
1+ const { assert } = require ( " console" )
22
33beforeAll ( async ( ) => {
44 // Test if Gatsby server is running
5- const response = await fetch ( ' http://localhost:8000/___graphql' )
5+ const response = await fetch ( " http://localhost:8000/___graphql" )
66 if ( response . status !== 200 ) {
7- throw new Error ( ' Gatsby server is not running.' )
7+ throw new Error ( " Gatsby server is not running." )
88 }
99} )
1010
1111async function fetchGraphQL ( query , variables ) {
12- return fetch ( ' http://localhost:8000/___graphql' , {
13- method : ' POST' ,
12+ return fetch ( " http://localhost:8000/___graphql" , {
13+ method : " POST" ,
1414 headers : {
15- ' Content-Type' : ' application/json' ,
15+ " Content-Type" : " application/json" ,
1616 } ,
1717 body : JSON . stringify ( {
1818 query,
1919 variables,
2020 } ) ,
21- } ) . then ( ( res ) => {
21+ } ) . then ( res => {
2222 return res . json ( )
2323 } )
2424}
2525
26- test ( ' resolves regular field reference' , async ( ) => {
26+ test ( " resolves regular field reference" , async ( ) => {
2727 const res = await fetchGraphQL ( `
2828 query {
2929 allSanityBook {
@@ -40,10 +40,10 @@ test('resolves regular field reference', async () => {
4040
4141 expect ( res . errors ) . toBeUndefined ( )
4242 const node = res . data . allSanityBook . edges [ 0 ] . node
43- expect ( node . publisher . name ) . toBe ( ' Bantam Books' )
43+ expect ( node . publisher . name ) . toBe ( " Bantam Books" )
4444} )
4545
46- test ( ' resolves inline cross dataset field reference' , async ( ) => {
46+ test ( " resolves inline cross dataset field reference" , async ( ) => {
4747 const res = await fetchGraphQL ( `
4848 query {
4949 allSanityBook {
@@ -60,7 +60,7 @@ test('resolves inline cross dataset field reference', async () => {
6060
6161 expect ( res . errors ) . toBeUndefined ( )
6262 const node = res . data . allSanityBook . edges [ 0 ] . node
63- expect ( node . author . name ) . toBe ( ' Neal Stephenson' )
63+ expect ( node . author . name ) . toBe ( " Neal Stephenson" )
6464} )
6565
6666test ( 'resolves inline cross dataset field reference that has multiple "to" types' , async ( ) => {
@@ -85,10 +85,10 @@ test('resolves inline cross dataset field reference that has multiple "to" types
8585
8686 expect ( res . errors ) . toBeUndefined ( )
8787 const node = res . data . allSanityBook . edges [ 0 ] . node
88- expect ( node . authorOrEditorInline . name ) . toBe ( ' Mrs Book Editor' )
88+ expect ( node . authorOrEditorInline . name ) . toBe ( " Mrs Book Editor" )
8989} )
9090
91- test ( ' resolves named cross dataset field reference' , async ( ) => {
91+ test ( " resolves named cross dataset field reference" , async ( ) => {
9292 const res = await fetchGraphQL ( `
9393 query {
9494 allSanityBook {
@@ -105,7 +105,7 @@ test('resolves named cross dataset field reference', async () => {
105105
106106 expect ( res . errors ) . toBeUndefined ( )
107107 const node = res . data . allSanityBook . edges [ 0 ] . node
108- expect ( node . extraAuthor . name ) . toBe ( ' Neal Stephenson' )
108+ expect ( node . extraAuthor . name ) . toBe ( " Neal Stephenson" )
109109} )
110110
111111test ( 'resolves named cross dataset field reference with multiple "to" types' , async ( ) => {
@@ -130,10 +130,10 @@ test('resolves named cross dataset field reference with multiple "to" types', as
130130
131131 expect ( res . errors ) . toBeUndefined ( )
132132 const node = res . data . allSanityBook . edges [ 0 ] . node
133- expect ( node . authorOrEditor . name ) . toBe ( ' Neal Stephenson' )
133+ expect ( node . authorOrEditor . name ) . toBe ( " Neal Stephenson" )
134134} )
135135
136- test ( ' it resolves arrays of references' , async ( ) => {
136+ test ( " it resolves arrays of references" , async ( ) => {
137137 const res = await fetchGraphQL ( `
138138 query {
139139 allSanityBook {
@@ -152,17 +152,17 @@ test('it resolves arrays of references', async () => {
152152 const node = res . data . allSanityBook . edges [ 0 ] . node
153153 const expected = [
154154 {
155- title : ' Science Fiction' ,
155+ title : " Science Fiction" ,
156156 } ,
157157 {
158- title : ' Cyberpunk' ,
158+ title : " Cyberpunk" ,
159159 } ,
160160 ]
161161
162162 expect ( node . genres ) . toEqual ( expected )
163163} )
164164
165- test ( ' it resolves arrays of cross dataset references' , async ( ) => {
165+ test ( " it resolves arrays of cross dataset references" , async ( ) => {
166166 const res = await fetchGraphQL ( `
167167 query {
168168 allSanityBook {
@@ -181,17 +181,17 @@ test('it resolves arrays of cross dataset references', async () => {
181181 const node = res . data . allSanityBook . edges [ 0 ] . node
182182 const expected = [
183183 {
184- name : ' Nom de Plume' ,
184+ name : " Nom de Plume" ,
185185 } ,
186186 {
187- name : ' Neal Stephenson' ,
187+ name : " Neal Stephenson" ,
188188 } ,
189189 ]
190190
191191 expect ( node . coauthors ) . toEqual ( expected )
192192} )
193193
194- test ( ' it resolves cross dataset references that are part of an Union' , async ( ) => {
194+ test ( " it resolves cross dataset references that are part of an Union" , async ( ) => {
195195 const res = await fetchGraphQL ( `
196196 query {
197197 allSanityBook {
@@ -212,7 +212,7 @@ test('it resolves cross dataset references that are part of an Union', async ()
212212 const node = res . data . allSanityBook . edges [ 0 ] . node
213213 const expected = [
214214 {
215- name : ' Neal Stephenson' ,
215+ name : " Neal Stephenson" ,
216216 } ,
217217 ]
218218
0 commit comments