


















@@ -48,6 +48,31 @@ vi.mock("./status.scan.runtime.js", () => ({
4848},
4949}));
505051+function firstGatewayRequest(): { method?: string; url?: string; token?: string } {
52+const call = mocks.callGateway.mock.calls[0];
53+if (!call) {
54+throw new Error("expected gateway call");
55+}
56+return call[0] as { method?: string; url?: string; token?: string };
57+}
58+59+type ChannelsTableCall = [
60+unknown,
61+{
62+includeSetupFallbackPlugins?: boolean;
63+showSecrets?: boolean;
64+sourceConfig?: unknown;
65+},
66+];
67+68+function firstChannelsTableCall(): ChannelsTableCall {
69+const call = mocks.buildChannelsTable.mock.calls[0];
70+if (!call) {
71+throw new Error("expected channels table call");
72+}
73+return call as ChannelsTableCall;
74+}
75+5176describe("collectStatusScanOverview", () => {
5277beforeEach(() => {
5378vi.clearAllMocks();
@@ -104,12 +129,12 @@ describe("collectStatusScanOverview", () => {
104129});
105130106131expect(mocks.callGateway).toHaveBeenCalledOnce();
107-const gatewayRequest = mocks.callGateway.mock.calls.at(0)?.[0];
132+const gatewayRequest = firstGatewayRequest();
108133expect(gatewayRequest?.method).toBe("channels.status");
109134expect(gatewayRequest?.url).toBe("ws://127.0.0.1:18789");
110135expect(gatewayRequest?.token).toBe("tok");
111136expect(mocks.buildChannelsTable).toHaveBeenCalledOnce();
112-const channelTableCall = mocks.buildChannelsTable.mock.calls.at(0);
137+const channelTableCall = firstChannelsTableCall();
113138expect(typeof channelTableCall?.[0]).toBe("object");
114139expect(channelTableCall?.[1]?.includeSetupFallbackPlugins).toBe(true);
115140expect(channelTableCall?.[1]?.showSecrets).toBe(false);
@@ -128,7 +153,7 @@ describe("collectStatusScanOverview", () => {
128153129154expect(mocks.callGateway).not.toHaveBeenCalled();
130155expect(mocks.buildChannelsTable).toHaveBeenCalledOnce();
131-const channelTableCall = mocks.buildChannelsTable.mock.calls.at(0);
156+const channelTableCall = firstChannelsTableCall();
132157expect(typeof channelTableCall?.[0]).toBe("object");
133158expect(channelTableCall?.[1]?.includeSetupFallbackPlugins).toBe(false);
134159expect(channelTableCall?.[1]?.showSecrets).toBe(false);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。