Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit b29fd62

Browse files
kyarikIvanGoncharov
authored andcommitted
Improve formatting of queries in tests
1 parent 9eef4db commit b29fd62

File tree

1 file changed

+52
-46
lines changed

1 file changed

+52
-46
lines changed

src/__tests__/http-test.ts

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function runTests(server: Server) {
163163

164164
const response = await app.request().get(
165165
urlString({
166-
query: '{test}',
166+
query: '{ test }',
167167
}),
168168
);
169169

@@ -529,7 +529,7 @@ function runTests(server: Server) {
529529

530530
const response = await app.request().get(
531531
urlString({
532-
query: '{test}',
532+
query: '{ test }',
533533
}),
534534
);
535535

@@ -555,7 +555,7 @@ function runTests(server: Server) {
555555

556556
const response = await app.request().get(
557557
urlString({
558-
query: '{test}',
558+
query: '{ test }',
559559
}),
560560
);
561561

@@ -564,7 +564,7 @@ function runTests(server: Server) {
564564
expect(seenRequest).to.not.equal(null);
565565
expect(seenResponse).to.not.equal(null);
566566
expect(seenParams).to.deep.equal({
567-
query: '{test}',
567+
query: '{ test }',
568568
operationName: null,
569569
variables: null,
570570
raw: false,
@@ -583,7 +583,7 @@ function runTests(server: Server) {
583583

584584
const response = await app.request().get(
585585
urlString({
586-
query: '{test}',
586+
query: '{ test }',
587587
}),
588588
);
589589

@@ -608,7 +608,7 @@ function runTests(server: Server) {
608608
const response = await app
609609
.request()
610610
.post(urlString())
611-
.send({ query: '{test}' });
611+
.send({ query: '{ test }' });
612612

613613
expect(response.text).to.equal('{"data":{"test":"Hello World"}}');
614614
});
@@ -642,7 +642,7 @@ function runTests(server: Server) {
642642
const response = await app
643643
.request()
644644
.post(urlString())
645-
.send(stringifyURLParams({ query: '{test}' }));
645+
.send(stringifyURLParams({ query: '{ test }' }));
646646

647647
expect(response.text).to.equal('{"data":{"test":"Hello World"}}');
648648
});
@@ -795,13 +795,13 @@ function runTests(server: Server) {
795795

796796
const response = await app.request().post(urlString()).send({
797797
query: `
798-
query helloYou { test(who: "You"), ...shared }
799-
query helloWorld { test(who: "World"), ...shared }
800-
query helloDolly { test(who: "Dolly"), ...shared }
801-
fragment shared on QueryRoot {
802-
shared: test(who: "Everyone")
803-
}
804-
`,
798+
query helloYou { test(who: "You"), ...shared }
799+
query helloWorld { test(who: "World"), ...shared }
800+
query helloDolly { test(who: "Dolly"), ...shared }
801+
fragment shared on QueryRoot {
802+
shared: test(who: "Everyone")
803+
}
804+
`,
805805
operationName: 'helloWorld',
806806
});
807807

@@ -958,8 +958,8 @@ function runTests(server: Server) {
958958
.field(
959959
'query',
960960
`mutation TestMutation {
961-
uploadFile { originalname, mimetype }
962-
}`,
961+
uploadFile { originalname, mimetype }
962+
}`,
963963
)
964964
.attach('file', Buffer.from('test'), 'test.txt');
965965

@@ -1043,7 +1043,7 @@ function runTests(server: Server) {
10431043

10441044
const response = await app.request().get(
10451045
urlString({
1046-
query: '{test}',
1046+
query: '{ test }',
10471047
}),
10481048
);
10491049

@@ -1074,7 +1074,7 @@ function runTests(server: Server) {
10741074
pretty = undefined;
10751075
const defaultResponse = await app.request().get(
10761076
urlString({
1077-
query: '{test}',
1077+
query: '{ test }',
10781078
}),
10791079
);
10801080

@@ -1083,7 +1083,7 @@ function runTests(server: Server) {
10831083
pretty = true;
10841084
const prettyResponse = await app.request().get(
10851085
urlString({
1086-
query: '{test}',
1086+
query: '{ test }',
10871087
pretty: '1',
10881088
}),
10891089
);
@@ -1102,7 +1102,7 @@ function runTests(server: Server) {
11021102
pretty = false;
11031103
const unprettyResponse = await app.request().get(
11041104
urlString({
1105-
query: '{test}',
1105+
query: '{ test }',
11061106
pretty: '0',
11071107
}),
11081108
);
@@ -1126,7 +1126,7 @@ function runTests(server: Server) {
11261126
}),
11271127
);
11281128

1129-
await app.request().get(urlString({ query: '{test}' }));
1129+
await app.request().get(urlString({ query: '{ test }' }));
11301130

11311131
expect(seenRequest).to.not.equal(undefined);
11321132
expect(seenResponse).to.not.equal(undefined);
@@ -1145,7 +1145,7 @@ function runTests(server: Server) {
11451145

11461146
const response = await app.request().get(
11471147
urlString({
1148-
query: '{thrower}',
1148+
query: '{ thrower }',
11491149
}),
11501150
);
11511151

@@ -1155,7 +1155,7 @@ function runTests(server: Server) {
11551155
errors: [
11561156
{
11571157
message: 'Throws!',
1158-
locations: [{ line: 1, column: 2 }],
1158+
locations: [{ line: 1, column: 3 }],
11591159
path: ['thrower'],
11601160
},
11611161
],
@@ -1217,7 +1217,7 @@ function runTests(server: Server) {
12171217

12181218
const response = await app.request().get(
12191219
urlString({
1220-
query: '{thrower}',
1220+
query: '{ thrower }',
12211221
}),
12221222
);
12231223

@@ -1279,7 +1279,7 @@ function runTests(server: Server) {
12791279

12801280
const response = await app.request().get(
12811281
urlString({
1282-
query: '{thrower}',
1282+
query: '{ thrower }',
12831283
}),
12841284
);
12851285

@@ -1289,7 +1289,7 @@ function runTests(server: Server) {
12891289
errors: [
12901290
{
12911291
message: 'Throws!',
1292-
locations: [{ line: 1, column: 2 }],
1292+
locations: [{ line: 1, column: 3 }],
12931293
stack: 'Stack trace',
12941294
},
12951295
],
@@ -1645,7 +1645,9 @@ function runTests(server: Server) {
16451645

16461646
app.put(urlString(), graphqlHTTP({ schema: TestSchema }));
16471647

1648-
const response = await app.request().put(urlString({ query: '{test}' }));
1648+
const response = await app
1649+
.request()
1650+
.put(urlString({ query: '{ test }' }));
16491651

16501652
expect(response.status).to.equal(405);
16511653
expect(response.get('allow')).to.equal('GET, POST');
@@ -1663,7 +1665,7 @@ function runTests(server: Server) {
16631665

16641666
const response = await app
16651667
.request()
1666-
.get(urlString({ query: '{test}' }))
1668+
.get(urlString({ query: '{ test }' }))
16671669
.set('Accept', 'text/html');
16681670

16691671
expect(response.status).to.equal(200);
@@ -1684,12 +1686,12 @@ function runTests(server: Server) {
16841686

16851687
const response = await app
16861688
.request()
1687-
.get(urlString({ query: '{test}' }))
1689+
.get(urlString({ query: '{ test }' }))
16881690
.set('Accept', 'text/html');
16891691

16901692
expect(response.status).to.equal(200);
16911693
expect(response.type).to.equal('text/html');
1692-
expect(response.text).to.include('{test}');
1694+
expect(response.text).to.include('{ test }');
16931695
expect(response.text).to.include('graphiql.min.js');
16941696
});
16951697

@@ -1729,7 +1731,7 @@ function runTests(server: Server) {
17291731

17301732
const response = await app
17311733
.request()
1732-
.get(urlString({ query: '{test}' }))
1734+
.get(urlString({ query: '{ test }' }))
17331735
.set('Accept', 'text/html');
17341736

17351737
expect(response.status).to.equal(200);
@@ -1918,7 +1920,7 @@ function runTests(server: Server) {
19181920

19191921
const response = await app
19201922
.request()
1921-
.get(urlString({ query: '{test}' }))
1923+
.get(urlString({ query: '{ test }' }))
19221924
.set('Accept', 'text/html,application/json');
19231925

19241926
expect(response.status).to.equal(200);
@@ -1939,7 +1941,7 @@ function runTests(server: Server) {
19391941

19401942
const response = await app
19411943
.request()
1942-
.get(urlString({ query: '{test}' }))
1944+
.get(urlString({ query: '{ test }' }))
19431945
.set('Accept', 'application/json,text/html');
19441946

19451947
expect(response.status).to.equal(200);
@@ -1960,7 +1962,7 @@ function runTests(server: Server) {
19601962

19611963
const response = await app
19621964
.request()
1963-
.get(urlString({ query: '{test}' }))
1965+
.get(urlString({ query: '{ test }' }))
19641966
.set('Accept', 'unknown');
19651967

19661968
expect(response.status).to.equal(200);
@@ -1981,7 +1983,7 @@ function runTests(server: Server) {
19811983

19821984
const response = await app
19831985
.request()
1984-
.get(urlString({ query: '{test}', raw: '' }))
1986+
.get(urlString({ query: '{ test }', raw: '' }))
19851987
.set('Accept', 'text/html');
19861988

19871989
expect(response.status).to.equal(200);
@@ -2061,7 +2063,7 @@ function runTests(server: Server) {
20612063

20622064
const response = await app
20632065
.request()
2064-
.get(urlString({ query: '{test}', raw: '' }))
2066+
.get(urlString({ query: '{ test }', raw: '' }))
20652067
.set('Accept', 'text/html');
20662068

20672069
expect(response.status).to.equal(200);
@@ -2085,7 +2087,7 @@ function runTests(server: Server) {
20852087

20862088
const response = await app.request().get(
20872089
urlString({
2088-
query: '{thrower}',
2090+
query: '{ thrower }',
20892091
}),
20902092
);
20912093

@@ -2127,7 +2129,7 @@ function runTests(server: Server) {
21272129

21282130
const response = await app.request().get(
21292131
urlString({
2130-
query: '{thrower}',
2132+
query: '{ thrower }',
21312133
}),
21322134
);
21332135

@@ -2166,7 +2168,9 @@ function runTests(server: Server) {
21662168
})),
21672169
);
21682170

2169-
const response = await app.request().get(urlString({ query: '{test}' }));
2171+
const response = await app
2172+
.request()
2173+
.get(urlString({ query: '{ test }' }));
21702174

21712175
expect(response.text).to.equal(
21722176
'{"data":{"test":"Hello World","test2":"Modification"}}',
@@ -2187,7 +2191,9 @@ function runTests(server: Server) {
21872191
})),
21882192
);
21892193

2190-
const response = await app.request().get(urlString({ query: '{test}' }));
2194+
const response = await app
2195+
.request()
2196+
.get(urlString({ query: '{ test }' }));
21912197

21922198
expect(response.status).to.equal(400);
21932199
expect(response.text).to.equal(
@@ -2208,7 +2214,7 @@ function runTests(server: Server) {
22082214
schema: TestSchema,
22092215
customParseFn(args) {
22102216
seenParseArgs = args;
2211-
return parse(new Source('{test}', 'Custom parse function'));
2217+
return parse(new Source('{ test }', 'Custom parse function'));
22122218
},
22132219
})),
22142220
);
@@ -2257,7 +2263,7 @@ function runTests(server: Server) {
22572263

22582264
const response = await app
22592265
.request()
2260-
.get(urlString({ query: '{test}', raw: '' }))
2266+
.get(urlString({ query: '{ test }', raw: '' }))
22612267
.set('Accept', 'text/html');
22622268

22632269
expect(response.status).to.equal(200);
@@ -2285,7 +2291,7 @@ function runTests(server: Server) {
22852291

22862292
const response = await app.request().get(
22872293
urlString({
2288-
query: '{thrower}',
2294+
query: '{ thrower }',
22892295
}),
22902296
);
22912297

@@ -2299,7 +2305,7 @@ function runTests(server: Server) {
22992305
errors: [
23002306
{
23012307
message: 'Throws!',
2302-
locations: [{ line: 1, column: 2 }],
2308+
locations: [{ line: 1, column: 3 }],
23032309
path: ['thrower'],
23042310
},
23052311
],
@@ -2324,7 +2330,7 @@ function runTests(server: Server) {
23242330

23252331
const response = await app
23262332
.request()
2327-
.get(urlString({ query: '{test}', raw: '' }))
2333+
.get(urlString({ query: '{ test }', raw: '' }))
23282334
.set('Accept', 'text/html');
23292335

23302336
expect(response.status).to.equal(200);
@@ -2348,7 +2354,7 @@ function runTests(server: Server) {
23482354

23492355
const response = await app
23502356
.request()
2351-
.get(urlString({ query: '{test}', raw: '' }))
2357+
.get(urlString({ query: '{ test }', raw: '' }))
23522358
.set('Accept', 'text/html');
23532359

23542360
expect(response.status).to.equal(200);

0 commit comments

Comments
 (0)