Skip to content

Commit abf7ac8

Browse files
authored
Add failing test (#50)
1 parent 179be26 commit abf7ac8

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

src/__tests__/client-id.test.ts

+32-17
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,37 @@ import { appWithClient, tableWithClient } from "./test-common";
55

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

8-
test("sanity - get named table", async () => {
9-
const table = await appWithClient.getTableNamed("Things");
10-
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
11-
const clientID = spy.mock.calls[0][1]["headers"]["X-Glide-Client-ID"];
12-
expect(clientID).toBeDefined();
13-
expect(clientID).toEqual(process.env.GLIDE_CLIENT_ID);
14-
expect(table).toBeDefined();
15-
});
8+
describe("client id sanity", () => {
9+
jest.setTimeout(60_000);
10+
11+
test("get named table", async () => {
12+
const table = await appWithClient.getTableNamed("Things");
13+
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
14+
const clientID = spy.mock.calls[0][1]["headers"]["X-Glide-Client-ID"];
15+
expect(clientID).toBeDefined();
16+
expect(clientID).toEqual(process.env.GLIDE_CLIENT_ID);
17+
expect(table).toBeDefined();
18+
});
19+
20+
test("get schema", async () => {
21+
const {
22+
data: { columns },
23+
} = await tableWithClient.getSchema();
24+
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
25+
const clientID = spy.mock.calls[0][1]["headers"]["X-Glide-Client-ID"];
26+
expect(clientID).toBeDefined();
27+
expect(clientID).toEqual(process.env.GLIDE_CLIENT_ID);
28+
expect(columns).toBeDefined();
29+
});
30+
31+
it("can add a row", async () => {
32+
const rowID = await tableWithClient.add({
33+
name: "Test Item",
34+
renamed: "Test Description",
35+
stock: 100,
36+
});
37+
expect(rowID).toBeDefined();
1638

17-
test("sanity - get named table", async () => {
18-
const {
19-
data: { columns },
20-
} = await tableWithClient.getSchema();
21-
const spy = (fetch as jest.Mock).mockImplementationOnce(fetch);
22-
const clientID = spy.mock.calls[0][1]["headers"]["X-Glide-Client-ID"];
23-
expect(clientID).toBeDefined();
24-
expect(clientID).toEqual(process.env.GLIDE_CLIENT_ID);
25-
expect(columns).toBeDefined();
39+
await tableWithClient.delete(rowID);
40+
});
2641
});

0 commit comments

Comments
 (0)