mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-28 22:24:23 +00:00
Move Delete Container call to use ARM when logged in with AAD (#110)
This commit is contained in:
44
src/Utils/arm/request.test.ts
Normal file
44
src/Utils/arm/request.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { armRequest } from "./request";
|
||||
|
||||
describe("ARM request", () => {
|
||||
it("should call window.fetch", async () => {
|
||||
window.fetch = jest.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => {
|
||||
return {};
|
||||
}
|
||||
});
|
||||
await armRequest({ apiVersion: "2001-01-01", host: "https://foo.com", path: "foo", method: "GET" });
|
||||
expect(window.fetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should poll for async operations", async () => {
|
||||
const headers = new Headers();
|
||||
headers.set("azure-asyncoperation", "https://foo.com/operationStatus");
|
||||
window.fetch = jest.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
headers,
|
||||
json: async () => {
|
||||
return { status: "Succeeded" };
|
||||
}
|
||||
});
|
||||
await armRequest({ apiVersion: "2001-01-01", host: "https://foo.com", path: "foo", method: "GET" });
|
||||
expect(window.fetch).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("should throw for failed async operations", async () => {
|
||||
const headers = new Headers();
|
||||
headers.set("azure-asyncoperation", "https://foo.com/operationStatus");
|
||||
window.fetch = jest.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
headers,
|
||||
json: async () => {
|
||||
return { status: "Failed" };
|
||||
}
|
||||
});
|
||||
await expect(() =>
|
||||
armRequest({ apiVersion: "2001-01-01", host: "https://foo.com", path: "foo", method: "GET" })
|
||||
).rejects.toThrow();
|
||||
expect(window.fetch).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user