diff --git a/src/commands/channels.remove.test.ts b/src/commands/channels.remove.test.ts index 0425c224f95..044f78d6577 100644 --- a/src/commands/channels.remove.test.ts +++ b/src/commands/channels.remove.test.ts @@ -65,6 +65,12 @@ vi.mock("../gateway/call.js", () => ({ const runtime = createTestRuntime(); +function firstWrittenChannelsConfig() { + return configMocks.writeConfigFile.mock.calls[0]?.[0] as + | { channels?: Record } + | undefined; +} + describe("channelsRemoveCommand", () => { beforeAll(async () => { ({ channelsRemoveCommand } = await import("./channels.js")); @@ -171,9 +177,7 @@ describe("channelsRemoveCommand", () => { expect(ensureChannelSetupPluginInstalled).not.toHaveBeenCalled(); expect(registryRefreshMocks.refreshPluginRegistryAfterConfigMutation).not.toHaveBeenCalled(); - const writtenConfig = configMocks.writeConfigFile.mock.calls.at(0)?.[0] as - | { channels?: Record } - | undefined; + const writtenConfig = firstWrittenChannelsConfig(); expect(writtenConfig?.channels?.["external-chat"]).toBeUndefined(); expect(runtime.error).not.toHaveBeenCalled(); expect(runtime.exit).not.toHaveBeenCalled(); @@ -237,9 +241,7 @@ describe("channelsRemoveCommand", () => { clientName: "gateway-client", deviceIdentity: null, }); - const writtenConfig = configMocks.writeConfigFile.mock.calls.at(0)?.[0] as - | { channels?: Record } - | undefined; + const writtenConfig = firstWrittenChannelsConfig(); expect(writtenConfig?.channels?.["external-chat"]).toBeUndefined(); }); });