Skip to content

Commit

Permalink
Add test checking non-boolean arg to warnOnFieldAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jul 16, 2024
1 parent eec30a3 commit 470e32a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/utilities/graphql/__tests__/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,24 @@ describe("isUnmaskedDocument", () => {
);
});

it("warns when passing non-boolean to warnOnFieldAccess", () => {
using consoleSpy = spyOnConsole("warn");
const query = gql`
query MyQuery @unmask(warnOnFieldAccess: "") {
myField
}
`;

const [isUnmasked, { warnOnFieldAccess }] = isUnmaskedDocument(query);

expect(isUnmasked).toBe(true);
expect(warnOnFieldAccess).toBe(true);
expect(consoleSpy.warn).toHaveBeenCalledTimes(1);
expect(consoleSpy.warn).toHaveBeenCalledWith(
"@unmask 'warnOnFieldAccess' argument must be of type boolean."
);
});

it("returns false when @unmask is not used", () => {
const query = gql`
query MyQuery {
Expand Down

0 comments on commit 470e32a

Please sign in to comment.