Skip to content

Commit

Permalink
Allow for long string literals inside tests (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Feb 12, 2019
1 parent 3caf46c commit 4b55f10
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 140 deletions.
3 changes: 1 addition & 2 deletions src/__tests__/starWarsIntrospection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ describe('Star Wars Introspection Tests', () => {
{
defaultValue: null,
description:
'If omitted, returns the hero of the whole saga. ' +
'If provided, returns the hero of that particular episode.',
'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
name: 'episode',
type: {
kind: 'ENUM',
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/starWarsSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ const queryType = new GraphQLObjectType({
args: {
episode: {
description:
'If omitted, returns the hero of the whole saga. ' +
'If provided, returns the hero of that particular episode.',
'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
type: episodeEnum,
},
},
Expand Down
7 changes: 2 additions & 5 deletions src/execution/__tests__/nonnull-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,7 @@ describe('Execute: handles non-nullable types', () => {
errors: [
{
message:
'Argument "cannotBeNull" of non-null type "String!" must ' +
'not be null.',
'Argument "cannotBeNull" of non-null type "String!" must not be null.',
locations: [{ line: 3, column: 42 }],
path: ['withNonNullArg'],
},
Expand Down Expand Up @@ -715,9 +714,7 @@ describe('Execute: handles non-nullable types', () => {
errors: [
{
message:
'Argument "cannotBeNull" of required type "String!" was ' +
'provided the variable "$testVar" which was not provided a ' +
'runtime value.',
'Argument "cannotBeNull" of required type "String!" was provided the variable "$testVar" which was not provided a runtime value.',
locations: [{ line: 3, column: 42 }],
path: ['withNonNullArg'],
},
Expand Down
38 changes: 12 additions & 26 deletions src/execution/__tests__/variables-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" got invalid value ' +
'{ a: "foo", b: "bar", c: null }; ' +
'Expected non-nullable type String! not to be null at value.c.',
'Variable "$input" got invalid value { a: "foo", b: "bar", c: null }; Expected non-nullable type String! not to be null at value.c.',
locations: [{ line: 2, column: 16 }],
},
],
Expand All @@ -388,8 +386,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" got invalid value "foo bar"; ' +
'Expected type TestInputObject to be an object.',
'Variable "$input" got invalid value "foo bar"; Expected type TestInputObject to be an object.',
locations: [{ line: 2, column: 16 }],
},
],
Expand All @@ -403,8 +400,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" got invalid value { a: "foo", b: "bar" }; ' +
'Field value.c of required type String! was not provided.',
'Variable "$input" got invalid value { a: "foo", b: "bar" }; Field value.c of required type String! was not provided.',
locations: [{ line: 2, column: 16 }],
},
],
Expand All @@ -423,14 +419,12 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" got invalid value { na: { a: "foo" } }; ' +
'Field value.na.c of required type String! was not provided.',
'Variable "$input" got invalid value { na: { a: "foo" } }; Field value.na.c of required type String! was not provided.',
locations: [{ line: 2, column: 18 }],
},
{
message:
'Variable "$input" got invalid value { na: { a: "foo" } }; ' +
'Field value.nb of required type String! was not provided.',
'Variable "$input" got invalid value { na: { a: "foo" } }; Field value.nb of required type String! was not provided.',
locations: [{ line: 2, column: 18 }],
},
],
Expand All @@ -447,9 +441,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" got invalid value ' +
'{ a: "foo", b: "bar", c: "baz", extra: "dog" }; ' +
'Field "extra" is not defined by type TestInputObject.',
'Variable "$input" got invalid value { a: "foo", b: "bar", c: "baz", extra: "dog" }; Field "extra" is not defined by type TestInputObject.',
locations: [{ line: 2, column: 16 }],
},
],
Expand Down Expand Up @@ -695,8 +687,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$value" got invalid value [1, 2, 3]; Expected type ' +
'String; String cannot represent a non string value: [1, 2, 3]',
'Variable "$value" got invalid value [1, 2, 3]; Expected type String; String cannot represent a non string value: [1, 2, 3]',
locations: [{ line: 2, column: 16 }],
},
],
Expand Down Expand Up @@ -724,8 +715,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Argument "input" of required type "String!" was provided the ' +
'variable "$foo" which was not provided a runtime value.',
'Argument "input" of required type "String!" was provided the variable "$foo" which was not provided a runtime value.',
locations: [{ line: 3, column: 50 }],
path: ['fieldWithNonNullableStringInput'],
},
Expand Down Expand Up @@ -843,8 +833,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" got invalid value ["A", null, "B"]; ' +
'Expected non-nullable type String! not to be null at value[1].',
'Variable "$input" got invalid value ["A", null, "B"]; Expected non-nullable type String! not to be null at value[1].',
locations: [{ line: 2, column: 16 }],
},
],
Expand Down Expand Up @@ -893,8 +882,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" got invalid value ["A", null, "B"]; ' +
'Expected non-nullable type String! not to be null at value[1].',
'Variable "$input" got invalid value ["A", null, "B"]; Expected non-nullable type String! not to be null at value[1].',
locations: [{ line: 2, column: 16 }],
},
],
Expand All @@ -913,8 +901,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" expected value of type "TestType!" which ' +
'cannot be used as an input type.',
'Variable "$input" expected value of type "TestType!" which cannot be used as an input type.',
locations: [{ line: 2, column: 24 }],
},
],
Expand All @@ -933,8 +920,7 @@ describe('Execute: Handles inputs', () => {
errors: [
{
message:
'Variable "$input" expected value of type "UnknownType!" which ' +
'cannot be used as an input type.',
'Variable "$input" expected value of type "UnknownType!" which cannot be used as an input type.',
locations: [{ line: 2, column: 24 }],
},
],
Expand Down
3 changes: 1 addition & 2 deletions src/subscription/__tests__/subscribe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ describe('Subscription Initialization Phase', () => {
errors: [
{
message:
'Variable "$priority" got invalid value "meow"; Expected ' +
'type Int; Int cannot represent non-integer value: "meow"',
'Variable "$priority" got invalid value "meow"; Expected type Int; Int cannot represent non-integer value: "meow"',
locations: [{ line: 2, column: 21 }],
},
],
Expand Down
47 changes: 15 additions & 32 deletions src/type/__tests__/definition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ describe('Type System: Scalars', () => {
}),
),
).to.throw(
'SomeScalar must provide "serialize" function. If this custom Scalar ' +
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' +
'functions are also provided.',
'SomeScalar must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.',
);
});

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

Expand Down Expand Up @@ -330,8 +326,7 @@ describe('Type System: Objects', () => {
fields: [{ field: GraphQLString }],
});
expect(() => objType.getFields()).to.throw(
'SomeObject fields must be an object with field names as keys or a ' +
'function which returns such an object.',
'SomeObject fields must be an object with field names as keys or a function which returns such an object.',
);
});

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

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

return schemaWithFieldType(OldObject);
}).to.throw(
'OldObject.field should provide "deprecationReason" instead ' +
'of "isDeprecated".',
'OldObject.field should provide "deprecationReason" instead of "isDeprecated".',
);
});

Expand Down Expand Up @@ -411,16 +404,14 @@ describe('Type System: Objects', () => {
it('rejects an empty Object field resolver', () => {
// $DisableFlowOnNegativeTest
expect(() => schemaWithObjectWithFieldResolver({})).to.throw(
'BadResolver.badField field resolver must be a function if provided, ' +
'but got: {}.',
'BadResolver.badField field resolver must be a function if provided, but got: {}.',
);
});

it('rejects a constant scalar value resolver', () => {
// $DisableFlowOnNegativeTest
expect(() => schemaWithObjectWithFieldResolver(0)).to.throw(
'BadResolver.badField field resolver must be a function if provided, ' +
'but got: 0.',
'BadResolver.badField field resolver must be a function if provided, but got: 0.',
);
});

Expand Down Expand Up @@ -553,8 +544,7 @@ describe('Type System: Unions', () => {
}),
),
).to.throw(
'Must provide Array of types or a function which returns such an array ' +
'for Union SomeUnion.',
'Must provide Array of types or a function which returns such an array for Union SomeUnion.',
);
});
});
Expand Down Expand Up @@ -647,8 +637,7 @@ describe('Type System: Enums', () => {
values: { FOO: null },
};
expect(() => new GraphQLEnumType(config)).to.throw(
'SomeEnum.FOO must refer to an object with a "value" key representing ' +
'an internal value but got: null.',
'SomeEnum.FOO must refer to an object with a "value" key representing an internal value but got: null.',
);
});

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

Expand All @@ -673,8 +661,7 @@ describe('Type System: Enums', () => {
},
};
expect(() => new GraphQLEnumType(config)).to.throw(
'SomeEnum.FOO should provide "deprecationReason" instead ' +
'of "isDeprecated".',
'SomeEnum.FOO should provide "deprecationReason" instead of "isDeprecated".',
);
});
});
Expand Down Expand Up @@ -710,8 +697,7 @@ describe('Type System: Input Objects', () => {
fields: [],
});
expect(() => inputObjType.getFields()).to.throw(
'SomeInputObject fields must be an object with field names as keys or a ' +
'function which returns such an object.',
'SomeInputObject fields must be an object with field names as keys or a function which returns such an object.',
);
});

Expand All @@ -722,8 +708,7 @@ describe('Type System: Input Objects', () => {
fields: () => [],
});
expect(() => inputObjType.getFields()).to.throw(
'SomeInputObject fields must be an object with field names as keys or a ' +
'function which returns such an object.',
'SomeInputObject fields must be an object with field names as keys or a function which returns such an object.',
);
});
});
Expand All @@ -738,8 +723,7 @@ describe('Type System: Input Objects', () => {
},
});
expect(() => inputObjType.getFields()).to.throw(
'SomeInputObject.f field has a resolve property, ' +
'but Input Types cannot define resolvers.',
'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.',
);
});

Expand All @@ -752,8 +736,7 @@ describe('Type System: Input Objects', () => {
},
});
expect(() => inputObjType.getFields()).to.throw(
'SomeInputObject.f field has a resolve property, ' +
'but Input Types cannot define resolvers.',
'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.',
);
});
});
Expand Down
6 changes: 2 additions & 4 deletions src/type/__tests__/enumType-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ describe('Type System: Enum Values', () => {
errors: [
{
message:
'Variable "$color" of type "String!" used in position ' +
'expecting type "Color".',
'Variable "$color" of type "String!" used in position expecting type "Color".',
locations: [{ line: 1, column: 8 }, { line: 1, column: 47 }],
},
],
Expand All @@ -308,8 +307,7 @@ describe('Type System: Enum Values', () => {
errors: [
{
message:
'Variable "$color" of type "Int!" used in position ' +
'expecting type "Color".',
'Variable "$color" of type "Int!" used in position expecting type "Color".',
locations: [{ line: 1, column: 8 }, { line: 1, column: 44 }],
},
],
Expand Down
21 changes: 7 additions & 14 deletions src/type/__tests__/introspection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1307,14 +1307,12 @@ describe('Introspection', () => {
{
name: 'mutationType',
description:
'If this server supports mutation, the type that ' +
'mutation operations will be rooted at.',
'If this server supports mutation, the type that mutation operations will be rooted at.',
},
{
name: 'subscriptionType',
description:
'If this server support subscription, the type ' +
'that subscription operations will be rooted at.',
'If this server support subscription, the type that subscription operations will be rooted at.',
},
{
name: 'directives',
Expand Down Expand Up @@ -1361,32 +1359,27 @@ describe('Introspection', () => {
},
{
description:
'Indicates this type is an object. ' +
'`fields` and `interfaces` are valid fields.',
'Indicates this type is an object. `fields` and `interfaces` are valid fields.',
name: 'OBJECT',
},
{
description:
'Indicates this type is an interface. ' +
'`fields` and `possibleTypes` are valid fields.',
'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.',
name: 'INTERFACE',
},
{
description:
'Indicates this type is a union. ' +
'`possibleTypes` is a valid field.',
'Indicates this type is a union. `possibleTypes` is a valid field.',
name: 'UNION',
},
{
description:
'Indicates this type is an enum. ' +
'`enumValues` is a valid field.',
'Indicates this type is an enum. `enumValues` is a valid field.',
name: 'ENUM',
},
{
description:
'Indicates this type is an input object. ' +
'`inputFields` is a valid field.',
'Indicates this type is an input object. `inputFields` is a valid field.',
name: 'INPUT_OBJECT',
},
{
Expand Down
Loading

0 comments on commit 4b55f10

Please sign in to comment.