File size: 1,125 Bytes
34810d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Channel option tests cover channel command option parsing and config resolution.
import { beforeEach, describe, expect, it, vi } from "vitest";
import { formatCliChannelOptions, resolveCliChannelOptions } from "./channel-options.js";

const readCliStartupMetadata = vi.hoisted(() => vi.fn());

vi.mock("./startup-metadata.js", () => ({ readCliStartupMetadata }));

describe("resolveCliChannelOptions", () => {
  beforeEach(() => {
    readCliStartupMetadata.mockReset();
  });

  it("uses precomputed startup metadata when available", () => {
    readCliStartupMetadata.mockReturnValue({
      channelOptions: ["cached", "", false, "quietchat", "cached"],
    });

    expect(resolveCliChannelOptions()).toEqual(["cached", "quietchat"]);
    expect(formatCliChannelOptions(["all"])).toBe("all|cached|quietchat");
  });

  it("falls back to generic channel text when metadata is missing", () => {
    readCliStartupMetadata.mockReturnValue(null);

    expect(resolveCliChannelOptions()).toEqual([]);
    expect(formatCliChannelOptions()).toBe("channel");
    expect(formatCliChannelOptions(["all"])).toBe("all");
  });
});