Skip to content

Commit 4b55f10

Browse files
Allow for long string literals inside tests (#1730)
1 parent 3caf46c commit 4b55f10

File tree

14 files changed

+67
-140
lines changed

14 files changed

+67
-140
lines changed

src/__tests__/starWarsIntrospection-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ describe('Star Wars Introspection Tests', () => {
346346
{
347347
defaultValue: null,
348348
description:
349-
'If omitted, returns the hero of the whole saga. ' +
350-
'If provided, returns the hero of that particular episode.',
349+
'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
351350
name: 'episode',
352351
type: {
353352
kind: 'ENUM',

src/__tests__/starWarsSchema.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ const queryType = new GraphQLObjectType({
262262
args: {
263263
episode: {
264264
description:
265-
'If omitted, returns the hero of the whole saga. ' +
266-
'If provided, returns the hero of that particular episode.',
265+
'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
267266
type: episodeEnum,
268267
},
269268
},

src/execution/__tests__/nonnull-test.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,7 @@ describe('Execute: handles non-nullable types', () => {
684684
errors: [
685685
{
686686
message:
687-
'Argument "cannotBeNull" of non-null type "String!" must ' +
688-
'not be null.',
687+
'Argument "cannotBeNull" of non-null type "String!" must not be null.',
689688
locations: [{ line: 3, column: 42 }],
690689
path: ['withNonNullArg'],
691690
},
@@ -715,9 +714,7 @@ describe('Execute: handles non-nullable types', () => {
715714
errors: [
716715
{
717716
message:
718-
'Argument "cannotBeNull" of required type "String!" was ' +
719-
'provided the variable "$testVar" which was not provided a ' +
720-
'runtime value.',
717+
'Argument "cannotBeNull" of required type "String!" was provided the variable "$testVar" which was not provided a runtime value.',
721718
locations: [{ line: 3, column: 42 }],
722719
path: ['withNonNullArg'],
723720
},

src/execution/__tests__/variables-test.js

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,7 @@ describe('Execute: Handles inputs', () => {
372372
errors: [
373373
{
374374
message:
375-
'Variable "$input" got invalid value ' +
376-
'{ a: "foo", b: "bar", c: null }; ' +
377-
'Expected non-nullable type String! not to be null at value.c.',
375+
'Variable "$input" got invalid value { a: "foo", b: "bar", c: null }; Expected non-nullable type String! not to be null at value.c.',
378376
locations: [{ line: 2, column: 16 }],
379377
},
380378
],
@@ -388,8 +386,7 @@ describe('Execute: Handles inputs', () => {
388386
errors: [
389387
{
390388
message:
391-
'Variable "$input" got invalid value "foo bar"; ' +
392-
'Expected type TestInputObject to be an object.',
389+
'Variable "$input" got invalid value "foo bar"; Expected type TestInputObject to be an object.',
393390
locations: [{ line: 2, column: 16 }],
394391
},
395392
],
@@ -403,8 +400,7 @@ describe('Execute: Handles inputs', () => {
403400
errors: [
404401
{
405402
message:
406-
'Variable "$input" got invalid value { a: "foo", b: "bar" }; ' +
407-
'Field value.c of required type String! was not provided.',
403+
'Variable "$input" got invalid value { a: "foo", b: "bar" }; Field value.c of required type String! was not provided.',
408404
locations: [{ line: 2, column: 16 }],
409405
},
410406
],
@@ -423,14 +419,12 @@ describe('Execute: Handles inputs', () => {
423419
errors: [
424420
{
425421
message:
426-
'Variable "$input" got invalid value { na: { a: "foo" } }; ' +
427-
'Field value.na.c of required type String! was not provided.',
422+
'Variable "$input" got invalid value { na: { a: "foo" } }; Field value.na.c of required type String! was not provided.',
428423
locations: [{ line: 2, column: 18 }],
429424
},
430425
{
431426
message:
432-
'Variable "$input" got invalid value { na: { a: "foo" } }; ' +
433-
'Field value.nb of required type String! was not provided.',
427+
'Variable "$input" got invalid value { na: { a: "foo" } }; Field value.nb of required type String! was not provided.',
434428
locations: [{ line: 2, column: 18 }],
435429
},
436430
],
@@ -447,9 +441,7 @@ describe('Execute: Handles inputs', () => {
447441
errors: [
448442
{
449443
message:
450-
'Variable "$input" got invalid value ' +
451-
'{ a: "foo", b: "bar", c: "baz", extra: "dog" }; ' +
452-
'Field "extra" is not defined by type TestInputObject.',
444+
'Variable "$input" got invalid value { a: "foo", b: "bar", c: "baz", extra: "dog" }; Field "extra" is not defined by type TestInputObject.',
453445
locations: [{ line: 2, column: 16 }],
454446
},
455447
],
@@ -695,8 +687,7 @@ describe('Execute: Handles inputs', () => {
695687
errors: [
696688
{
697689
message:
698-
'Variable "$value" got invalid value [1, 2, 3]; Expected type ' +
699-
'String; String cannot represent a non string value: [1, 2, 3]',
690+
'Variable "$value" got invalid value [1, 2, 3]; Expected type String; String cannot represent a non string value: [1, 2, 3]',
700691
locations: [{ line: 2, column: 16 }],
701692
},
702693
],
@@ -724,8 +715,7 @@ describe('Execute: Handles inputs', () => {
724715
errors: [
725716
{
726717
message:
727-
'Argument "input" of required type "String!" was provided the ' +
728-
'variable "$foo" which was not provided a runtime value.',
718+
'Argument "input" of required type "String!" was provided the variable "$foo" which was not provided a runtime value.',
729719
locations: [{ line: 3, column: 50 }],
730720
path: ['fieldWithNonNullableStringInput'],
731721
},
@@ -843,8 +833,7 @@ describe('Execute: Handles inputs', () => {
843833
errors: [
844834
{
845835
message:
846-
'Variable "$input" got invalid value ["A", null, "B"]; ' +
847-
'Expected non-nullable type String! not to be null at value[1].',
836+
'Variable "$input" got invalid value ["A", null, "B"]; Expected non-nullable type String! not to be null at value[1].',
848837
locations: [{ line: 2, column: 16 }],
849838
},
850839
],
@@ -893,8 +882,7 @@ describe('Execute: Handles inputs', () => {
893882
errors: [
894883
{
895884
message:
896-
'Variable "$input" got invalid value ["A", null, "B"]; ' +
897-
'Expected non-nullable type String! not to be null at value[1].',
885+
'Variable "$input" got invalid value ["A", null, "B"]; Expected non-nullable type String! not to be null at value[1].',
898886
locations: [{ line: 2, column: 16 }],
899887
},
900888
],
@@ -913,8 +901,7 @@ describe('Execute: Handles inputs', () => {
913901
errors: [
914902
{
915903
message:
916-
'Variable "$input" expected value of type "TestType!" which ' +
917-
'cannot be used as an input type.',
904+
'Variable "$input" expected value of type "TestType!" which cannot be used as an input type.',
918905
locations: [{ line: 2, column: 24 }],
919906
},
920907
],
@@ -933,8 +920,7 @@ describe('Execute: Handles inputs', () => {
933920
errors: [
934921
{
935922
message:
936-
'Variable "$input" expected value of type "UnknownType!" which ' +
937-
'cannot be used as an input type.',
923+
'Variable "$input" expected value of type "UnknownType!" which cannot be used as an input type.',
938924
locations: [{ line: 2, column: 24 }],
939925
},
940926
],

src/subscription/__tests__/subscribe-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ describe('Subscription Initialization Phase', () => {
475475
errors: [
476476
{
477477
message:
478-
'Variable "$priority" got invalid value "meow"; Expected ' +
479-
'type Int; Int cannot represent non-integer value: "meow"',
478+
'Variable "$priority" got invalid value "meow"; Expected type Int; Int cannot represent non-integer value: "meow"',
480479
locations: [{ line: 2, column: 21 }],
481480
},
482481
],

src/type/__tests__/definition-test.js

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ describe('Type System: Scalars', () => {
114114
}),
115115
),
116116
).to.throw(
117-
'SomeScalar must provide "serialize" function. If this custom Scalar ' +
118-
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' +
119-
'functions are also provided.',
117+
'SomeScalar must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.',
120118
);
121119
});
122120

@@ -130,9 +128,7 @@ describe('Type System: Scalars', () => {
130128
}),
131129
),
132130
).to.throw(
133-
'SomeScalar must provide "serialize" function. If this custom Scalar ' +
134-
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' +
135-
'functions are also provided.',
131+
'SomeScalar must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.',
136132
);
137133
});
138134

@@ -330,8 +326,7 @@ describe('Type System: Objects', () => {
330326
fields: [{ field: GraphQLString }],
331327
});
332328
expect(() => objType.getFields()).to.throw(
333-
'SomeObject fields must be an object with field names as keys or a ' +
334-
'function which returns such an object.',
329+
'SomeObject fields must be an object with field names as keys or a function which returns such an object.',
335330
);
336331
});
337332

@@ -344,8 +339,7 @@ describe('Type System: Objects', () => {
344339
},
345340
});
346341
expect(() => objType.getFields()).to.throw(
347-
'SomeObject fields must be an object with field names as keys or a ' +
348-
'function which returns such an object.',
342+
'SomeObject fields must be an object with field names as keys or a function which returns such an object.',
349343
);
350344
});
351345

@@ -377,8 +371,7 @@ describe('Type System: Objects', () => {
377371

378372
return schemaWithFieldType(OldObject);
379373
}).to.throw(
380-
'OldObject.field should provide "deprecationReason" instead ' +
381-
'of "isDeprecated".',
374+
'OldObject.field should provide "deprecationReason" instead of "isDeprecated".',
382375
);
383376
});
384377

@@ -411,16 +404,14 @@ describe('Type System: Objects', () => {
411404
it('rejects an empty Object field resolver', () => {
412405
// $DisableFlowOnNegativeTest
413406
expect(() => schemaWithObjectWithFieldResolver({})).to.throw(
414-
'BadResolver.badField field resolver must be a function if provided, ' +
415-
'but got: {}.',
407+
'BadResolver.badField field resolver must be a function if provided, but got: {}.',
416408
);
417409
});
418410

419411
it('rejects a constant scalar value resolver', () => {
420412
// $DisableFlowOnNegativeTest
421413
expect(() => schemaWithObjectWithFieldResolver(0)).to.throw(
422-
'BadResolver.badField field resolver must be a function if provided, ' +
423-
'but got: 0.',
414+
'BadResolver.badField field resolver must be a function if provided, but got: 0.',
424415
);
425416
});
426417

@@ -553,8 +544,7 @@ describe('Type System: Unions', () => {
553544
}),
554545
),
555546
).to.throw(
556-
'Must provide Array of types or a function which returns such an array ' +
557-
'for Union SomeUnion.',
547+
'Must provide Array of types or a function which returns such an array for Union SomeUnion.',
558548
);
559549
});
560550
});
@@ -647,8 +637,7 @@ describe('Type System: Enums', () => {
647637
values: { FOO: null },
648638
};
649639
expect(() => new GraphQLEnumType(config)).to.throw(
650-
'SomeEnum.FOO must refer to an object with a "value" key representing ' +
651-
'an internal value but got: null.',
640+
'SomeEnum.FOO must refer to an object with a "value" key representing an internal value but got: null.',
652641
);
653642
});
654643

@@ -659,8 +648,7 @@ describe('Type System: Enums', () => {
659648
values: { FOO: 10 },
660649
};
661650
expect(() => new GraphQLEnumType(config)).to.throw(
662-
'SomeEnum.FOO must refer to an object with a "value" key representing ' +
663-
'an internal value but got: 10.',
651+
'SomeEnum.FOO must refer to an object with a "value" key representing an internal value but got: 10.',
664652
);
665653
});
666654

@@ -673,8 +661,7 @@ describe('Type System: Enums', () => {
673661
},
674662
};
675663
expect(() => new GraphQLEnumType(config)).to.throw(
676-
'SomeEnum.FOO should provide "deprecationReason" instead ' +
677-
'of "isDeprecated".',
664+
'SomeEnum.FOO should provide "deprecationReason" instead of "isDeprecated".',
678665
);
679666
});
680667
});
@@ -710,8 +697,7 @@ describe('Type System: Input Objects', () => {
710697
fields: [],
711698
});
712699
expect(() => inputObjType.getFields()).to.throw(
713-
'SomeInputObject fields must be an object with field names as keys or a ' +
714-
'function which returns such an object.',
700+
'SomeInputObject fields must be an object with field names as keys or a function which returns such an object.',
715701
);
716702
});
717703

@@ -722,8 +708,7 @@ describe('Type System: Input Objects', () => {
722708
fields: () => [],
723709
});
724710
expect(() => inputObjType.getFields()).to.throw(
725-
'SomeInputObject fields must be an object with field names as keys or a ' +
726-
'function which returns such an object.',
711+
'SomeInputObject fields must be an object with field names as keys or a function which returns such an object.',
727712
);
728713
});
729714
});
@@ -738,8 +723,7 @@ describe('Type System: Input Objects', () => {
738723
},
739724
});
740725
expect(() => inputObjType.getFields()).to.throw(
741-
'SomeInputObject.f field has a resolve property, ' +
742-
'but Input Types cannot define resolvers.',
726+
'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.',
743727
);
744728
});
745729

@@ -752,8 +736,7 @@ describe('Type System: Input Objects', () => {
752736
},
753737
});
754738
expect(() => inputObjType.getFields()).to.throw(
755-
'SomeInputObject.f field has a resolve property, ' +
756-
'but Input Types cannot define resolvers.',
739+
'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.',
757740
);
758741
});
759742
});

src/type/__tests__/enumType-test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ describe('Type System: Enum Values', () => {
292292
errors: [
293293
{
294294
message:
295-
'Variable "$color" of type "String!" used in position ' +
296-
'expecting type "Color".',
295+
'Variable "$color" of type "String!" used in position expecting type "Color".',
297296
locations: [{ line: 1, column: 8 }, { line: 1, column: 47 }],
298297
},
299298
],
@@ -308,8 +307,7 @@ describe('Type System: Enum Values', () => {
308307
errors: [
309308
{
310309
message:
311-
'Variable "$color" of type "Int!" used in position ' +
312-
'expecting type "Color".',
310+
'Variable "$color" of type "Int!" used in position expecting type "Color".',
313311
locations: [{ line: 1, column: 8 }, { line: 1, column: 44 }],
314312
},
315313
],

src/type/__tests__/introspection-test.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,14 +1307,12 @@ describe('Introspection', () => {
13071307
{
13081308
name: 'mutationType',
13091309
description:
1310-
'If this server supports mutation, the type that ' +
1311-
'mutation operations will be rooted at.',
1310+
'If this server supports mutation, the type that mutation operations will be rooted at.',
13121311
},
13131312
{
13141313
name: 'subscriptionType',
13151314
description:
1316-
'If this server support subscription, the type ' +
1317-
'that subscription operations will be rooted at.',
1315+
'If this server support subscription, the type that subscription operations will be rooted at.',
13181316
},
13191317
{
13201318
name: 'directives',
@@ -1361,32 +1359,27 @@ describe('Introspection', () => {
13611359
},
13621360
{
13631361
description:
1364-
'Indicates this type is an object. ' +
1365-
'`fields` and `interfaces` are valid fields.',
1362+
'Indicates this type is an object. `fields` and `interfaces` are valid fields.',
13661363
name: 'OBJECT',
13671364
},
13681365
{
13691366
description:
1370-
'Indicates this type is an interface. ' +
1371-
'`fields` and `possibleTypes` are valid fields.',
1367+
'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.',
13721368
name: 'INTERFACE',
13731369
},
13741370
{
13751371
description:
1376-
'Indicates this type is a union. ' +
1377-
'`possibleTypes` is a valid field.',
1372+
'Indicates this type is a union. `possibleTypes` is a valid field.',
13781373
name: 'UNION',
13791374
},
13801375
{
13811376
description:
1382-
'Indicates this type is an enum. ' +
1383-
'`enumValues` is a valid field.',
1377+
'Indicates this type is an enum. `enumValues` is a valid field.',
13841378
name: 'ENUM',
13851379
},
13861380
{
13871381
description:
1388-
'Indicates this type is an input object. ' +
1389-
'`inputFields` is a valid field.',
1382+
'Indicates this type is an input object. `inputFields` is a valid field.',
13901383
name: 'INPUT_OBJECT',
13911384
},
13921385
{

0 commit comments

Comments
 (0)