-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
316 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
|
||
// import { | ||
// GraphQLID, | ||
// GraphQLInt, | ||
// GraphQLFloat, | ||
// GraphQLString, | ||
// GraphQLBoolean, | ||
// } from '../../type/scalars'; | ||
// import { | ||
// GraphQLList, | ||
// GraphQLNonNull, | ||
// GraphQLScalarType, | ||
// GraphQLEnumType, | ||
// GraphQLInputObjectType, | ||
// } from '../../type/definition'; | ||
|
||
import { parseConstValue } from '../../language/parser'; | ||
import { literalToValue } from '../literalToValue'; | ||
|
||
describe('literalToValue', () => { | ||
it('converts null', () => { | ||
expect(literalToValue(parseConstValue('null'))).to.equal(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
|
||
import type { ValueNode } from '../../language/ast'; | ||
import { parseValue as _parseValue } from '../../language/parser'; | ||
import { replaceASTVariables } from '../replaceASTVariables'; | ||
|
||
function parseValue(ast: string): ValueNode { | ||
return _parseValue(ast, { noLocation: true }); | ||
} | ||
|
||
describe('replaceASTVariables', () => { | ||
it('does not change simple AST', () => { | ||
const ast = parseValue('null') | ||
expect(replaceASTVariables(ast, undefined)).to.equal(ast); | ||
}); | ||
|
||
it('replaces simple Variables', () => { | ||
const ast = parseValue('$var') | ||
expect(replaceASTVariables(ast, {var:123})).to.deep.equal(parseValue('123')); | ||
}); | ||
|
||
it('replaces nested Variables', () => { | ||
const ast = parseValue('{ foo: [ $var ], bar: $var }') | ||
expect(replaceASTVariables(ast, {var:123})).to.deep.equal(parseValue('{ foo: [ 123 ], bar: 123 }')); | ||
}); | ||
|
||
it('replaces missing Variables with null', () => { | ||
const ast = parseValue('$var') | ||
expect(replaceASTVariables(ast, undefined)).to.deep.equal(parseValue('null')); | ||
}); | ||
|
||
it('replaces missing Variables in lists with null', () => { | ||
const ast = parseValue('[1, $var]') | ||
expect(replaceASTVariables(ast, undefined)).to.deep.equal(parseValue('[1, null]')); | ||
}); | ||
|
||
it('omits missing Variables from objects', () => { | ||
const ast = parseValue('{ foo: 1, bar: $var }') | ||
expect(replaceASTVariables(ast, undefined)).to.deep.equal(parseValue('{ foo: 1 }')); | ||
}); | ||
}); |
Oops, something went wrong.