Skip to content

Commit

Permalink
Add failing test (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyll authored Feb 27, 2024
1 parent 179be26 commit abf7ac8
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions src/__tests__/client-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,37 @@ import { appWithClient, tableWithClient } from "./test-common";

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

test("sanity - get named table", async () => {
const table = await appWithClient.getTableNamed("Things");
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
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();
});
describe("client id sanity", () => {
jest.setTimeout(60_000);

test("get named table", async () => {
const table = await appWithClient.getTableNamed("Things");
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
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();
});

test("get schema", async () => {
const {
data: { columns },
} = await tableWithClient.getSchema();
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
const clientID = spy.mock.calls[0][1]["headers"]["X-Glide-Client-ID"];
expect(clientID).toBeDefined();
expect(clientID).toEqual(process.env.GLIDE_CLIENT_ID);
expect(columns).toBeDefined();
});

it("can add a row", async () => {
const rowID = await tableWithClient.add({
name: "Test Item",
renamed: "Test Description",
stock: 100,
});
expect(rowID).toBeDefined();

test("sanity - get named table", async () => {
const {
data: { columns },
} = await tableWithClient.getSchema();
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
const clientID = spy.mock.calls[0][1]["headers"]["X-Glide-Client-ID"];
expect(clientID).toBeDefined();
expect(clientID).toEqual(process.env.GLIDE_CLIENT_ID);
expect(columns).toBeDefined();
await tableWithClient.delete(rowID);
});
});

0 comments on commit abf7ac8

Please sign in to comment.