Skip to content

Commit

Permalink
Fix some typos in stripIgnoredCharacters docs+tests (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored and IvanGoncharov committed May 17, 2019
1 parent 110d0c1 commit b6e63ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
32 changes: 16 additions & 16 deletions src/utilities/__tests__/stripIgnoredCharacters-test.js
Expand Up @@ -118,7 +118,7 @@ describe('stripIgnoredCharacters', () => {
);
});

it('asserts that an invalid source was provided', () => {
it('asserts that a valid source was provided', () => {
// $DisableFlowOnNegativeTest
expect(() => stripIgnoredCharacters({})).to.throw(
'Must provide string or Source. Received: {}',
Expand Down Expand Up @@ -220,7 +220,7 @@ describe('stripIgnoredCharacters', () => {
}
});

it('strips ignored tokens beetween punctuator tokens', () => {
it('strips ignored tokens between punctuator tokens', () => {
expectStripped('[,)').toEqual('[)');
expectStripped('[\r)').toEqual('[)');
expectStripped('[\r\r)').toEqual('[)');
Expand All @@ -246,7 +246,7 @@ describe('stripIgnoredCharacters', () => {
}
});

it('strips ignored tokens beetween punctuator and non-punctuator tokens', () => {
it('strips ignored tokens between punctuator and non-punctuator tokens', () => {
expectStripped('[,1').toEqual('[1');
expectStripped('[\r1').toEqual('[1');
expectStripped('[\r\r1').toEqual('[1');
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('stripIgnoredCharacters', () => {
}
});

it('strips ignored tokens beetween non-punctuator and punctuator tokens', () => {
it('strips ignored tokens between non-punctuator and punctuator tokens', () => {
expectStripped('1,[').toEqual('1[');
expectStripped('1\r[').toEqual('1[');
expectStripped('1\r\r[').toEqual('1[');
Expand Down Expand Up @@ -307,7 +307,7 @@ describe('stripIgnoredCharacters', () => {
}
});

it('replace ignored tokens beetween non-punctuator tokens and spead with space', () => {
it('replace ignored tokens between non-punctuator tokens and spread with space', () => {
expectStripped('a ...').toEqual('a ...');
expectStripped('1 ...').toEqual('1 ...');
expectStripped('1 ... ...').toEqual('1 ......');
Expand All @@ -331,7 +331,7 @@ describe('stripIgnoredCharacters', () => {
}
});

it('replace ignored tokens beetween non-punctuator tokens with space', () => {
it('replace ignored tokens between non-punctuator tokens with space', () => {
expectStripped('1 2').toStayTheSame();
expectStripped('"" ""').toStayTheSame();
expectStripped('a b').toStayTheSame();
Expand Down Expand Up @@ -384,21 +384,21 @@ describe('stripIgnoredCharacters', () => {
expectStripped('""",,"""').toStayTheSame();
expectStripped('""",|"""').toStayTheSame();

const ignoredTokensWithoutFormating = ignoredTokens.filter(
const ignoredTokensWithoutFormatting = ignoredTokens.filter(
token => ['\n', '\r', '\r\n', '\t', ' '].indexOf(token) === -1,
);
for (const ignored of ignoredTokensWithoutFormating) {
for (const ignored of ignoredTokensWithoutFormatting) {
expectStripped('"""|' + ignored + '|"""').toStayTheSame();

for (const anotherIgnored of ignoredTokensWithoutFormating) {
for (const anotherIgnored of ignoredTokensWithoutFormatting) {
expectStripped(
'"""|' + ignored + anotherIgnored + '|"""',
).toStayTheSame();
}
}

expectStripped(
'"""|' + ignoredTokensWithoutFormating.join('') + '|"""',
'"""|' + ignoredTokensWithoutFormatting.join('') + '|"""',
).toStayTheSame();
});

Expand Down Expand Up @@ -434,13 +434,13 @@ describe('stripIgnoredCharacters', () => {
expectStrippedString('"""\n a\n b"""').toEqual('"""a\nb"""');
expectStrippedString('"""\na\n b\nc"""').toEqual('"""a\n b\nc"""');

// Testing with length >5 is taking exponentially more time however it
// highly recommended to test with increased limit if you make any change
const maxCombinationLenght = 5;
// Testing with length >5 is taking exponentially more time. However it is
// highly recommended to test with increased limit if you make any change.
const maxCombinationLength = 5;
const possibleChars = ['\n', ' ', '"', 'a', '\\'];
const numPossibleChars = possibleChars.length;
let numCombinations = 1;
for (let length = 1; length < maxCombinationLenght; ++length) {
for (let length = 1; length < maxCombinationLength; ++length) {
numCombinations *= numPossibleChars;
for (let combination = 0; combination < numCombinations; ++combination) {
let testStr = '"""';
Expand Down Expand Up @@ -469,7 +469,7 @@ describe('stripIgnoredCharacters', () => {
}
});

it('strips kitchen sink query but maintain the exact same AST', () => {
it('strips kitchen sink query but maintains the exact same AST', () => {
const strippedQuery = stripIgnoredCharacters(kitchenSinkQuery);
expect(stripIgnoredCharacters(strippedQuery)).to.equal(strippedQuery);

Expand All @@ -478,7 +478,7 @@ describe('stripIgnoredCharacters', () => {
expect(strippedAST).to.deep.equal(queryAST);
});

it('strips kitchen sink SDL but maintain the exact same AST', () => {
it('strips kitchen sink SDL but maintains the exact same AST', () => {
const strippedSDL = stripIgnoredCharacters(kitchenSinkSDL);
expect(stripIgnoredCharacters(strippedSDL)).to.equal(strippedSDL);

Expand Down
12 changes: 6 additions & 6 deletions src/utilities/stripIgnoredCharacters.js
Expand Up @@ -25,15 +25,15 @@ import {
* - Comma
* - BlockString indentation
*
* Note: It is required to have delimiter character between neighboring
* non-Punctuator tokes and this function always use single space as delimiter.
* Note: It is required to have a delimiter character between neighboring
* non-punctuator tokens and this function always uses single space as delimiter.
*
* It is guaranteed that both input and output documents if parsed would result
* in the exact same AST except for nodes location.
*
* Warning: It guaranteed that this function will always produce stable results
* however, it's not guaranteed that it will stay the same between different
* releases due to bugfixes or changes in the GraphQL Specification.
* Warning: It is guaranteed that this function will always produce stable results.
* However, it's not guaranteed that it will stay the same between different
* releases due to bugfixes or changes in the GraphQL specification.
*
* Query example:
*
Expand Down Expand Up @@ -87,7 +87,7 @@ export function stripIgnoredCharacters(source: string | Source): string {
/**
* Every two non-punctuator tokens should have space between them.
* Also prevent case of non-punctuator token following by spread resulting
* in invalid toke (e.g. `1...` is invalid Float token).
* in invalid token (e.g. `1...` is invalid Float token).
*/
const isNonPunctuator = !isPunctuatorToken(currentToken);
if (wasLastAddedTokenNonPunctuator) {
Expand Down

0 comments on commit b6e63ec

Please sign in to comment.