Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printError shouldn't return trailing new line #1983

Merged
merged 1 commit into from Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/error/__tests__/printError-test.js
Expand Up @@ -32,7 +32,7 @@ describe('printError', () => {
new Source('*', 'Test', { line: 9, column: 1 }),
[0],
);
expect(printError(singleDigit)).to.equal(dedent`
expect(printError(singleDigit) + '\n').to.equal(dedent`
Single digit line number with no padding
Test:9:1
Expand All @@ -46,7 +46,7 @@ describe('printError', () => {
new Source('*\n', 'Test', { line: 9, column: 1 }),
[0],
);
expect(printError(doubleDigit)).to.equal(dedent`
expect(printError(doubleDigit) + '\n').to.equal(dedent`
Left padded first line number
Test:9:1
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('printError', () => {
fieldB.type,
]);

expect(printError(error)).to.equal(dedent`
expect(printError(error) + '\n').to.equal(dedent`
Example error with two nodes
SourceA:2:10
Expand Down
2 changes: 1 addition & 1 deletion src/error/printError.js
Expand Up @@ -29,7 +29,7 @@ export function printError(error: GraphQLError): string {
}
return printedLocations.length === 0
? error.message
: [error.message, ...printedLocations].join('\n\n') + '\n';
: [error.message, ...printedLocations].join('\n\n');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/language/__tests__/lexer-test.js
Expand Up @@ -118,7 +118,7 @@ describe('Lexer', () => {
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
expect(String(caughtError) + '\n').to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".
GraphQL request:3:5
Expand All @@ -138,7 +138,7 @@ describe('Lexer', () => {
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
expect(String(caughtError) + '\n').to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".
foo.js:13:6
Expand All @@ -157,7 +157,7 @@ describe('Lexer', () => {
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
expect(String(caughtError) + '\n').to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".
foo.js:1:5
Expand Down
4 changes: 2 additions & 2 deletions src/language/__tests__/parser-test.js
Expand Up @@ -44,7 +44,7 @@ describe('Parser', () => {
locations: [{ line: 1, column: 2 }],
});

expect(String(caughtError)).to.equal(dedent`
expect(String(caughtError) + '\n').to.equal(dedent`
Syntax Error: Expected Name, found <EOF>
GraphQL request:1:2
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('Parser', () => {
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
expect(String(caughtError) + '\n').to.equal(dedent`
Syntax Error: Expected {, found <EOF>
MyQuery.graphql:1:6
Expand Down
20 changes: 9 additions & 11 deletions src/utilities/__tests__/stripIgnoredCharacters-test.js
Expand Up @@ -82,16 +82,6 @@ function expectStripped(docString) {
toStayTheSame() {
this.toEqual(docString);
},
toThrow(expectedStringifyError) {
let catchedError;

try {
stripIgnoredCharacters(docString);
} catch (e) {
catchedError = e;
}
expect(String(catchedError)).to.equal(expectedStringifyError);
},
};

function inspectStr(str) {
Expand Down Expand Up @@ -155,7 +145,15 @@ describe('stripIgnoredCharacters', () => {
});

it('report document with invalid token', () => {
expectStripped('{ foo(arg: "\n"').toThrow(dedent`
let catchedError;

try {
stripIgnoredCharacters('{ foo(arg: "\n"');
} catch (e) {
catchedError = e;
}

expect(String(catchedError) + '\n').to.equal(dedent`
Syntax Error: Unterminated string.
GraphQL request:1:13
Expand Down