From a766555c0bd9204accdeb5d0430293ca6d02d402 Mon Sep 17 00:00:00 2001 From: Kiran Date: Fri, 23 Mar 2018 21:49:34 +0530 Subject: [PATCH] Added mutation tests for getDirectivesFromDocument (#2995) --- .../src/__tests__/transform.ts | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/apollo-utilities/src/__tests__/transform.ts b/packages/apollo-utilities/src/__tests__/transform.ts index da87ae22d73..39e20e9f100 100644 --- a/packages/apollo-utilities/src/__tests__/transform.ts +++ b/packages/apollo-utilities/src/__tests__/transform.ts @@ -882,7 +882,38 @@ describe('getDirectivesFromDocument', () => { const doc = getDirectivesFromDocument([{ name: 'client' }], query); expect(print(doc)).toBe(print(expected)); }); + it('should get mutation with client fields', () => { + const query = gql` + mutation { + login @client + } + `; + const expected = gql` + mutation { + login @client + } + `; + const doc = getDirectivesFromDocument([{ name: 'client' }], query); + expect(print(doc)).toBe(print(expected)); + }); + + it('should get mutation fields of client only', () => { + const query = gql` + mutation { + login @client + updateUser + } + `; + + const expected = gql` + mutation { + login @client + } + `; + const doc = getDirectivesFromDocument([{ name: 'client' }], query); + expect(print(doc)).toBe(print(expected)); + }); describe('includeAllFragments', () => { it('= false: should remove the values without a client in fragment', () => { const query = gql` @@ -951,5 +982,4 @@ describe('getDirectivesFromDocument', () => { const doc = getDirectivesFromDocument([{ name: 'client' }], query, true); expect(print(doc)).toBe(print(expected)); }); - }); });