Files
cosmos-explorer/src/Common/dataAccess/readCollection.test.ts
Sunil Kumar Yadav 531df811da Remove userContext.defaultExperience (#730)
Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
2021-04-28 14:25:04 -05:00

35 lines
919 B
TypeScript

jest.mock("../CosmosClient");
import { AuthType } from "../../AuthType";
import { DatabaseAccount } from "../../Contracts/DataModels";
import { updateUserContext } from "../../UserContext";
import { client } from "../CosmosClient";
import { readCollection } from "./readCollection";
describe("readCollection", () => {
beforeAll(() => {
updateUserContext({
authType: AuthType.ResourceToken,
databaseAccount: {
name: "test",
} as DatabaseAccount,
apiType: "SQL",
});
});
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();
});
});