1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add tests for KubeApi.watch timeout (#4367)

This commit is contained in:
Jari Kolehmainen 2021-11-17 16:34:05 +02:00 committed by GitHub
parent c9d4f37ead
commit 2446b6cf9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -293,4 +293,37 @@ describe("KubeApi", () => {
await api.delete({ name: "foo", namespace: "default", propagationPolicy: "Orphan" });
});
});
describe("watch", () => {
let api: TestKubeApi;
beforeEach(() => {
api = new TestKubeApi({
request,
objectConstructor: TestKubeObject,
});
});
it("sends a valid watch request", () => {
const spy = jest.spyOn(request, "getResponse");
(fetch as any).mockResponse(async () => {
return {};
});
api.watch({ namespace: "kube-system" });
expect(spy).toHaveBeenCalledWith("/api/v1/namespaces/kube-system/pods?watch=1&resourceVersion=", expect.anything(), expect.anything());
});
it("sends timeout as a query parameter", async () => {
const spy = jest.spyOn(request, "getResponse");
(fetch as any).mockResponse(async () => {
return {};
});
api.watch({ namespace: "kube-system", timeout: 60 });
expect(spy).toHaveBeenCalledWith("/api/v1/namespaces/kube-system/pods?watch=1&resourceVersion=", { query: { timeoutSeconds: 60 }}, expect.anything());
});
});
});