History

test(desktop): cover password store through startup (#10287)

Julius Marminge committed 2 months ago

Commit 181e4511 parent cabac782 files · +16 −39Browse files

Unified · Split

2 files
  1. apps/desktop/src/app/DesktopPreReadyPlatform.test.ts +15 −38
  2. apps/desktop/src/app/DesktopPreReadyPlatform.ts +1 −1
apps/desktop/src/app/DesktopPreReadyPlatform.test.ts+15−38
@@ -37,45 +37,22 @@ describe("DesktopPreReadyPlatform", () => { · 36 unmodified lines
3737 registerSchemesMock.mockReset();
3838 });
3939
40− it("reads an explicit Electron command-line switch value", () => {
41− const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
42− {
43− hasSwitch: (switchName) => switchName === "password-store",
44− getSwitchValue: (switchName) => {
45− assert.equal(switchName, "password-store");
46− return "basic";
47− },
48− },
49− "password-store",
40+ it.effect("preserves an explicit Linux password-store switch", () => {
41+ hasSwitchMock.mockImplementation((switchName) => switchName === "password-store");
42+ getSwitchValueMock.mockReturnValue(" basic ");
43+
44+ return Effect.gen(function* () {
45+ const options = yield* DesktopPreReadyPlatform.DesktopPreReadyElectronOptions;
46+
47+ assert.equal(options.linuxPasswordStoreCommandLine, "basic");
48+ assert.isFalse(appendSwitchMock.mock.calls.some(([name]) => name === "password-store"));
49+ }).pipe(
50+ Effect.provide(
51+ DesktopPreReadyPlatform.layer.pipe(
52+ Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
53+ ),
54+ ),
5055 );
51−
52− assert.equal(value, "basic");
53− });
54−
55− it("treats valueless Electron command-line switches as absent", () => {
56− const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
57− {
58− hasSwitch: () => true,
59− getSwitchValue: () => "",
60− },
61− "password-store",
62− );
63−
64− assert.isNull(value);
65− });
66−
67− it("returns null for missing Electron command-line switches", () => {
68− const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(
69− {
70− hasSwitch: () => false,
71− getSwitchValue: () => {
72− throw new Error("Unexpected switch value read.");
73− },
74− },
75− "password-store",
76− );
77−
78− assert.isNull(value);
7956 });
8057
8158 it.effect(
apps/desktop/src/app/DesktopPreReadyPlatform.ts+1−1
@@ -17,7 +17,7 @@ export interface DesktopPreReadyCommandLineReader { · 16 unmodified lines
1717 readonly getSwitchValue: (switchName: string) => string;
1818 }
1919
20−export function readCommandLineSwitchValue(
20+function readCommandLineSwitchValue(
2121 commandLine: DesktopPreReadyCommandLineReader,
2222 switchName: string,
2323 ): string | null {