mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix tests
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
cae880ad85
commit
d5c8ddc2ac
@ -30,14 +30,14 @@ jest.mock("tcp-port-used")
|
|||||||
import { Cluster } from "../cluster"
|
import { Cluster } from "../cluster"
|
||||||
import { KubeAuthProxy } from "../kube-auth-proxy"
|
import { KubeAuthProxy } from "../kube-auth-proxy"
|
||||||
import { getFreePort } from "../port"
|
import { getFreePort } from "../port"
|
||||||
import { broadcastIpc } from "../../common/ipc"
|
import { broadcastMessage } from "../../common/ipc"
|
||||||
import { ChildProcess, spawn, SpawnOptions } from "child_process"
|
import { ChildProcess, spawn, SpawnOptions } from "child_process"
|
||||||
import { bundledKubectlPath, Kubectl } from "../kubectl"
|
import { bundledKubectlPath, Kubectl } from "../kubectl"
|
||||||
import { mock, MockProxy } from 'jest-mock-extended';
|
import { mock, MockProxy } from 'jest-mock-extended';
|
||||||
import { waitUntilUsed } from 'tcp-port-used';
|
import { waitUntilUsed } from 'tcp-port-used';
|
||||||
import { Readable } from "stream"
|
import { Readable } from "stream"
|
||||||
|
|
||||||
const mockBroadcastIpc = broadcastIpc as jest.MockedFunction<typeof broadcastIpc>
|
const mockBroadcastIpc = broadcastMessage as jest.MockedFunction<typeof broadcastMessage>
|
||||||
const mockSpawn = spawn as jest.MockedFunction<typeof spawn>
|
const mockSpawn = spawn as jest.MockedFunction<typeof spawn>
|
||||||
const mockWaitUntilUsed = waitUntilUsed as jest.MockedFunction<typeof waitUntilUsed>
|
const mockWaitUntilUsed = waitUntilUsed as jest.MockedFunction<typeof waitUntilUsed>
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ describe("kube auth proxy tests", () => {
|
|||||||
await kap.run()
|
await kap.run()
|
||||||
listeners["error"]({ message: "foobarbat" })
|
listeners["error"]({ message: "foobarbat" })
|
||||||
|
|
||||||
expect(mockBroadcastIpc).toBeCalledWith({ channel: "kube-auth:foobar", args: [{ data: "foobarbat", error: true }] })
|
expect(mockBroadcastIpc).toBeCalledWith("kube-auth:foobar", { data: "foobarbat", error: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call spawn and broadcast exit", async () => {
|
it("should call spawn and broadcast exit", async () => {
|
||||||
@ -100,7 +100,7 @@ describe("kube auth proxy tests", () => {
|
|||||||
await kap.run()
|
await kap.run()
|
||||||
listeners["exit"](0)
|
listeners["exit"](0)
|
||||||
|
|
||||||
expect(mockBroadcastIpc).toBeCalledWith({ channel: "kube-auth:foobar", args: [{ data: "proxy exited with code: 0", error: false }] })
|
expect(mockBroadcastIpc).toBeCalledWith("kube-auth:foobar", { data: "proxy exited with code: 0", error: false })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call spawn and broadcast errors from stderr", async () => {
|
it("should call spawn and broadcast errors from stderr", async () => {
|
||||||
@ -108,7 +108,7 @@ describe("kube auth proxy tests", () => {
|
|||||||
await kap.run()
|
await kap.run()
|
||||||
listeners["stderr/data"]("an error")
|
listeners["stderr/data"]("an error")
|
||||||
|
|
||||||
expect(mockBroadcastIpc).toBeCalledWith({ channel: "kube-auth:foobar", args: [{ data: "an error", error: true }] })
|
expect(mockBroadcastIpc).toBeCalledWith("kube-auth:foobar", { data: "an error", error: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call spawn and broadcast stdout serving info", async () => {
|
it("should call spawn and broadcast stdout serving info", async () => {
|
||||||
@ -116,7 +116,7 @@ describe("kube auth proxy tests", () => {
|
|||||||
await kap.run()
|
await kap.run()
|
||||||
listeners["stdout/data"]("Starting to serve on")
|
listeners["stdout/data"]("Starting to serve on")
|
||||||
|
|
||||||
expect(mockBroadcastIpc).toBeCalledWith({ channel: "kube-auth:foobar", args: [{ data: "Authentication proxy started\n" }] })
|
expect(mockBroadcastIpc).toBeCalledWith("kube-auth:foobar", { data: "Authentication proxy started\n" })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call spawn and broadcast stdout other info", async () => {
|
it("should call spawn and broadcast stdout other info", async () => {
|
||||||
@ -124,7 +124,7 @@ describe("kube auth proxy tests", () => {
|
|||||||
await kap.run()
|
await kap.run()
|
||||||
listeners["stdout/data"]("some info")
|
listeners["stdout/data"]("some info")
|
||||||
|
|
||||||
expect(mockBroadcastIpc).toBeCalledWith({ channel: "kube-auth:foobar", args: [{ data: "some info" }] })
|
expect(mockBroadcastIpc).toBeCalledWith("kube-auth:foobar", { data: "some info" })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user