Files
cosmos-explorer/src/Common/dataAccess/readCollection.test.ts
2021-02-22 14:43:58 -06:00

36 lines
1.0 KiB
TypeScript

jest.mock("../CosmosClient");
import { AuthType } from "../../AuthType";
import { DatabaseAccount } from "../../Contracts/DataModels";
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
import { client } from "../CosmosClient";
import { readCollection } from "./readCollection";
import { updateUserContext } from "../../UserContext";
describe("readCollection", () => {
beforeAll(() => {
updateUserContext({
authType: AuthType.ResourceToken,
databaseAccount: {
name: "test",
} as DatabaseAccount,
defaultExperience: DefaultAccountExperienceType.DocumentDB,
});
});
it("should call SDK if logged in with resource token", async () => {
(client as jest.Mock).mockReturnValue({
database: () => {
return {
container: () => {
return {
read: (): unknown => ({}),
};
},
};
},
});
await readCollection("database", "collection");
expect(client).toHaveBeenCalled();
});
});