mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 00:41:31 +00:00
35 lines
919 B
TypeScript
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();
|
|
});
|
|
});
|