Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/__tests__/client-id.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
require("dotenv").config();
import fetch from "cross-fetch";

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

test("sanity", async () => {
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();
});

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();
});
9 changes: 9 additions & 0 deletions src/__tests__/test-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ export const table = app.table({
},
});

export const tableWithClient = appWithClient.table({
table: "native-table-MX8xNW5WWoJhW4fwEeN7",
columns: {
name: { type: "string", name: "Name" },
stock: { type: "number", name: "Description" },
renamed: { type: "string", name: "yPXU2" },
},
});

export const bigTable = app.table({
table: "native-table-9500db9c-fa75-4968-82e3-9d53437893e8",
columns: {
Expand Down