Skip to content

Commit

Permalink
Add parser tests for accepting non keywords, take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
swolchok committed Jul 28, 2015
1 parent e614782 commit fa70ff8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/language/__tests__/parser.js
Expand Up @@ -119,6 +119,34 @@ fragment MissingOn Type
expect(() => parse(kitchenSink)).to.not.throw();
});

it('allows non-keywords anywhere a Name is allowed', () => {
const nonKeywords = [
'on',
'fragment',
'query',
'mutation',
'true',
'false'
];
nonKeywords.forEach((keyword) => {
let fragmentName = keyword;
// You can't define or reference a fragment named `on`.
if (keyword === 'on') {
fragmentName = 'a';
}
expect(() => {
parse(`query ${keyword} {
... ${fragmentName}
... on ${keyword} { field }
}
fragment ${fragmentName} on Type {
${keyword}(${keyword}: $${keyword}) @${keyword}(${keyword}: ${keyword})
}`
);
}).to.not.throw();
});
});

it('parse creates ast', () => {

var source = new Source(`{
Expand Down

0 comments on commit fa70ff8

Please sign in to comment.