























@@ -25,6 +25,10 @@ const manifestRegistryMocks = vi.hoisted(() => ({
2525loadPluginManifestRegistry: vi.fn(() => ({ plugins: [], diagnostics: [] })),
2626}));
272728+const discoveryMocks = vi.hoisted(() => ({
29+isCatalogChannelInstalled: vi.fn(() => false),
30+}));
31+2832vi.mock("../channels/plugins/catalog.js", async () => {
2933const actual = await vi.importActual<typeof import("../channels/plugins/catalog.js")>(
3034"../channels/plugins/catalog.js",
@@ -45,6 +49,20 @@ vi.mock("../plugins/manifest-registry.js", async () => {
4549};
4650});
475152+vi.mock("./channel-setup/discovery.js", () => ({
53+isCatalogChannelInstalled: discoveryMocks.isCatalogChannelInstalled,
54+}));
55+56+vi.mock("../channels/plugins/bundled.js", async () => {
57+const actual = await vi.importActual<typeof import("../channels/plugins/bundled.js")>(
58+"../channels/plugins/bundled.js",
59+);
60+return {
61+ ...actual,
62+getBundledChannelPlugin: vi.fn(() => undefined),
63+};
64+});
65+4866vi.mock("./channel-setup/plugin-install.js", async () => {
4967const actual = await vi.importActual<typeof import("./channel-setup/plugin-install.js")>(
5068"./channel-setup/plugin-install.js",
@@ -250,6 +268,8 @@ describe("channelsAddCommand", () => {
250268plugins: [],
251269diagnostics: [],
252270});
271+discoveryMocks.isCatalogChannelInstalled.mockClear();
272+discoveryMocks.isCatalogChannelInstalled.mockReturnValue(false);
253273vi.mocked(ensureChannelSetupPluginInstalled).mockClear();
254274vi.mocked(ensureChannelSetupPluginInstalled).mockImplementation(async ({ cfg }) => ({
255275 cfg,
@@ -321,13 +341,13 @@ describe("channelsAddCommand", () => {
321341expect(ensureChannelSetupPluginInstalled).toHaveBeenCalledWith(
322342expect.objectContaining({ entry: catalogEntry }),
323343);
324-expect(loadChannelSetupPluginRegistrySnapshotForChannel).not.toHaveBeenCalled();
344+expect(loadChannelSetupPluginRegistrySnapshotForChannel).toHaveBeenCalledTimes(1);
325345expect(configMocks.writeConfigFile).toHaveBeenCalledWith(
326346expect.objectContaining({
327347channels: {
328-msteams: {
348+msteams: expect.objectContaining({
329349enabled: true,
330-},
350+}),
331351},
332352}),
333353);
@@ -349,6 +369,7 @@ describe("channelsAddCommand", () => {
349369],
350370diagnostics: [],
351371});
372+discoveryMocks.isCatalogChannelInstalled.mockReturnValue(true);
352373registerMSTeamsSetupPlugin("msteams");
353374354375await channelsAddCommand(
@@ -362,13 +383,13 @@ describe("channelsAddCommand", () => {
362383);
363384364385expect(ensureChannelSetupPluginInstalled).not.toHaveBeenCalled();
365-expect(loadChannelSetupPluginRegistrySnapshotForChannel).not.toHaveBeenCalled();
386+expect(loadChannelSetupPluginRegistrySnapshotForChannel).toHaveBeenCalledTimes(1);
366387expect(configMocks.writeConfigFile).toHaveBeenCalledWith(
367388expect.objectContaining({
368389channels: {
369-msteams: {
390+msteams: expect.objectContaining({
370391enabled: true,
371-},
392+}),
372393},
373394}),
374395);
@@ -435,13 +456,13 @@ describe("channelsAddCommand", () => {
435456{ hasFlags: true },
436457);
437458438-expect(loadChannelSetupPluginRegistrySnapshotForChannel).not.toHaveBeenCalled();
459+expect(loadChannelSetupPluginRegistrySnapshotForChannel).toHaveBeenCalledTimes(1);
439460expect(configMocks.writeConfigFile).toHaveBeenCalledWith(
440461expect.objectContaining({
441462channels: {
442-msteams: {
463+msteams: expect.objectContaining({
443464enabled: true,
444-},
465+}),
445466},
446467}),
447468);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。