diff --git a/src/execution/__tests__/directives.js b/src/execution/__tests__/directives.js index d7f09877f6..1cc9ab7963 100644 --- a/src/execution/__tests__/directives.js +++ b/src/execution/__tests__/directives.js @@ -212,42 +212,84 @@ describe('Execute: handles directives', () => { }); }); - describe('works on fragment', () => { - it('if false omits fragment', async () => { + describe('works on anonymous inline fragment', () => { + it('if false omits anonymous inline fragment', async () => { var q = ` query Q { a - ...Frag + ... @include(if: false) { + b + } } - fragment Frag on TestType @include(if: false) { - b + `; + return expect(await executeTestQuery(q)).to.deep.equal({ + data: { a: 'a' } + }); + }); + + it('if true includes anonymous inline fragment', async () => { + var q = ` + query Q { + a + ... @include(if: true) { + b + } + } + `; + return expect(await executeTestQuery(q)).to.deep.equal({ + data: { a: 'a', b: 'b' } + }); + }); + it('unless false includes anonymous inline fragment', async () => { + var q = ` + query Q { + a + ... @skip(if: false) { + b + } + } + `; + return expect(await executeTestQuery(q)).to.deep.equal({ + data: { a: 'a', b: 'b' } + }); + }); + it('unless true includes anonymous inline fragment', async () => { + var q = ` + query Q { + a + ... @skip(if: true) { + b + } } `; return expect(await executeTestQuery(q)).to.deep.equal({ data: { a: 'a' } }); }); - it('if true includes fragment', async () => { + }); + + describe('works on fragment', () => { + it('if false omits fragment', async () => { var q = ` query Q { a ...Frag } - fragment Frag on TestType @include(if: true) { + fragment Frag on TestType @include(if: false) { b } `; return expect(await executeTestQuery(q)).to.deep.equal({ - data: { a: 'a', b: 'b' } + data: { a: 'a' } }); }); - it('unless false includes fragment', async () => { + it('if true includes fragment', async () => { var q = ` query Q { a ...Frag } - fragment Frag on TestType @skip(if: false) { + fragment Frag on TestType @include(if: true) { b } `; @@ -255,18 +297,18 @@ describe('Execute: handles directives', () => { data: { a: 'a', b: 'b' } }); }); - it('unless true omits fragment', async () => { + it('unless false includes fragment', async () => { var q = ` query Q { a ...Frag } - fragment Frag on TestType @skip(if: true) { + fragment Frag on TestType @skip(if: false) { b } `; return expect(await executeTestQuery(q)).to.deep.equal({ - data: { a: 'a' } + data: { a: 'a', b: 'b' } }); }); });