Skip to content

Commit

Permalink
Add regression tests for issue reported in #2921.
Browse files Browse the repository at this point in the history
Specifically, make sure to test all possibilities which might come in here.
  • Loading branch information
abernix committed Jun 26, 2019
1 parent 490c93a commit 32deb9f
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ describe('isDirectiveDefined', () => {
) on FIELD_DEFINITION | OBJECT | INTERFACE
`;

describe('When passed a DocumentNode', () => {
it('returns false when a directive is not defined', () => {
expect(isDirectiveDefined(gql(noCacheControl), 'cacheControl')).toBe(
false,
);
});
it('returns true when a directive is defined', () => {
expect(isDirectiveDefined(gql(hasCacheControl), 'cacheControl')).toBe(
true,
);
});
});

describe('When passed an array of DocumentNode', () => {
it('returns false when a directive is not defined', () => {
expect(isDirectiveDefined([gql(noCacheControl)], 'cacheControl')).toBe(
Expand All @@ -36,6 +49,15 @@ describe('isDirectiveDefined', () => {
});
});

describe('When passed an array of strings', () => {
it('returns false when a directive is not defined', () => {
expect(isDirectiveDefined([noCacheControl], 'cacheControl')).toBe(false);
});
it('returns true when a directive is defined', () => {
expect(isDirectiveDefined([hasCacheControl], 'cacheControl')).toBe(true);
});
});

describe('When passed a string', () => {
it('returns false when a directive is not defined', () => {
expect(isDirectiveDefined(noCacheControl, 'cacheControl')).toBe(false);
Expand Down

0 comments on commit 32deb9f

Please sign in to comment.