Skip to content

Commit

Permalink
Add mocked test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyll committed Feb 26, 2024
1 parent 798f713 commit d6b9572
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/__tests__/client-id.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
require("dotenv").config();
import fetch from "cross-fetch";

import { appWithClient } from "./test-common";

jest.mock("cross-fetch", () => jest.fn(jest.requireActual("cross-fetch") as any));

test("sanity", async () => {
const table = await appWithClient.getTableNamed("Things");
const spy = (fetch as jest.Mock).mockImplementationOnce(() => {
return Promise.resolve(new Response(JSON.stringify({ data: [] }), { status: 200 }));
});
const clientID = spy.mock.calls[0][1]["headers"]["X-Glide-Client-ID"];
expect(clientID).toBeDefined();
expect(clientID).toEqual(process.env.GLIDE_CLIENT_ID);
expect(table).toBeDefined();
});

0 comments on commit d6b9572

Please sign in to comment.