mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-24 03:11:32 +00:00
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
jest.mock("../../Utils/arm/request");
|
|
jest.mock("../MessageHandler");
|
|
jest.mock("../CosmosClient");
|
|
import { deleteCollection } from "./deleteCollection";
|
|
import { armRequest } from "../../Utils/arm/request";
|
|
import { AuthType } from "../../AuthType";
|
|
import { client } from "../CosmosClient";
|
|
import { updateUserContext } from "../../UserContext";
|
|
import { DatabaseAccount } from "../../Contracts/DataModels";
|
|
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
|
|
|
describe("deleteCollection", () => {
|
|
beforeAll(() => {
|
|
updateUserContext({
|
|
databaseAccount: {
|
|
name: "test"
|
|
} as DatabaseAccount,
|
|
defaultExperience: DefaultAccountExperienceType.DocumentDB
|
|
});
|
|
});
|
|
|
|
it("should call ARM if logged in with AAD", async () => {
|
|
window.authType = AuthType.AAD;
|
|
await deleteCollection("database", "collection");
|
|
expect(armRequest).toHaveBeenCalled();
|
|
});
|
|
|
|
it("should call SDK if not logged in with non-AAD method", async () => {
|
|
window.authType = AuthType.MasterKey;
|
|
(client as jest.Mock).mockReturnValue({
|
|
database: () => {
|
|
return {
|
|
container: () => {
|
|
return {
|
|
delete: (): unknown => undefined
|
|
};
|
|
}
|
|
};
|
|
}
|
|
});
|
|
await deleteCollection("database", "collection");
|
|
expect(client).toHaveBeenCalled();
|
|
});
|
|
});
|