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

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-11-17 12:21:23 +02:00
parent 561cd4d75b
commit ee7971c2cf

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());
});
});
});