Skip to content

Commit

Permalink
Added mutation tests for getDirectivesFromDocument (#2995)
Browse files Browse the repository at this point in the history
  • Loading branch information
akiran authored and James Baxley committed Mar 23, 2018
1 parent 3051219 commit a766555
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion packages/apollo-utilities/src/__tests__/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -951,5 +982,4 @@ describe('getDirectivesFromDocument', () => {
const doc = getDirectivesFromDocument([{ name: 'client' }], query, true);
expect(print(doc)).toBe(print(expected));
});
});
});

0 comments on commit a766555

Please sign in to comment.