From 5bbfa4025502d031c4122e2549a59a7238905a61 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 19 Apr 2026 02:26:50 +0100 Subject: [PATCH] test: share channel add config assertion --- src/commands/channels.add.test.ts | 42 +++++++++++-------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/commands/channels.add.test.ts b/src/commands/channels.add.test.ts index 483b840f42d..2634cc74b77 100644 --- a/src/commands/channels.add.test.ts +++ b/src/commands/channels.add.test.ts @@ -65,6 +65,18 @@ function listConfiguredAccountIds( return []; } +function expectExternalChatEnabledConfigWrite() { + expect(configMocks.writeConfigFile).toHaveBeenCalledWith( + expect.objectContaining({ + channels: { + "external-chat": expect.objectContaining({ + enabled: true, + }), + }, + }), + ); +} + function createLifecycleChatAddTestPlugin(): ChannelPlugin { const resolveLifecycleChatAccount = ( cfg: Parameters>[0], @@ -314,15 +326,7 @@ describe("channelsAddCommand", () => { expect.objectContaining({ entry: catalogEntry }), ); expect(loadChannelSetupPluginRegistrySnapshotForChannel).toHaveBeenCalledTimes(1); - expect(configMocks.writeConfigFile).toHaveBeenCalledWith( - expect.objectContaining({ - channels: { - "external-chat": expect.objectContaining({ - enabled: true, - }), - }, - }), - ); + expectExternalChatEnabledConfigWrite(); expect(runtime.error).not.toHaveBeenCalled(); expect(runtime.exit).not.toHaveBeenCalled(); @@ -343,15 +347,7 @@ describe("channelsAddCommand", () => { expect(ensureChannelSetupPluginInstalled).not.toHaveBeenCalled(); expect(loadChannelSetupPluginRegistrySnapshotForChannel).toHaveBeenCalledTimes(1); - expect(configMocks.writeConfigFile).toHaveBeenCalledWith( - expect.objectContaining({ - channels: { - "external-chat": expect.objectContaining({ - enabled: true, - }), - }, - }), - ); + expectExternalChatEnabledConfigWrite(); }); it("uses the installed plugin id when channel and plugin ids differ", async () => { @@ -416,15 +412,7 @@ describe("channelsAddCommand", () => { ); expect(loadChannelSetupPluginRegistrySnapshotForChannel).toHaveBeenCalledTimes(1); - expect(configMocks.writeConfigFile).toHaveBeenCalledWith( - expect.objectContaining({ - channels: { - "external-chat": expect.objectContaining({ - enabled: true, - }), - }, - }), - ); + expectExternalChatEnabledConfigWrite(); expect(runtime.error).not.toHaveBeenCalled(); expect(runtime.exit).not.toHaveBeenCalled(); });