test: dedupe channels remove mock reads

This commit is contained in:
Peter Steinberger
2026-05-12 23:52:31 +01:00
parent 87f5fb3ab2
commit 4cd356fa2a

View File

@@ -65,6 +65,12 @@ vi.mock("../gateway/call.js", () => ({
const runtime = createTestRuntime();
function firstWrittenChannelsConfig() {
return configMocks.writeConfigFile.mock.calls[0]?.[0] as
| { channels?: Record<string, unknown> }
| 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<string, unknown> }
| 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<string, unknown> }
| undefined;
const writtenConfig = firstWrittenChannelsConfig();
expect(writtenConfig?.channels?.["external-chat"]).toBeUndefined();
});
});