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
37 registerSchemesMock.mockReset();37 registerSchemesMock.mockReset();
38 });38 });
39 39
40 it("reads an explicit Electron command-line switch value", () => {40 it.effect("preserves an explicit Linux password-store switch", () => {
41 const value = DesktopPreReadyPlatform.readCommandLineSwitchValue(41 hasSwitchMock.mockImplementation((switchName) => switchName === "password-store");
42 {42 getSwitchValueMock.mockReturnValue(" basic ");
43 hasSwitch: (switchName) => switchName === "password-store",43
44 getSwitchValue: (switchName) => {44 return Effect.gen(function* () {
45 assert.equal(switchName, "password-store");45 const options = yield* DesktopPreReadyPlatform.DesktopPreReadyElectronOptions;
46 return "basic";46
47 },47 assert.equal(options.linuxPasswordStoreCommandLine, "basic");
48 },48 assert.isFalse(appendSwitchMock.mock.calls.some(([name]) => name === "password-store"));
49 "password-store",49 }).pipe(
50 Effect.provide(
51 DesktopPreReadyPlatform.layer.pipe(
52 Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
53 ),
54 ),
50 );55 );
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);
79 });56 });
80 57
81 it.effect(58 it.effect(
apps/desktop/src/app/DesktopPreReadyPlatform.ts+1−1
@@ -17,7 +17,7 @@ export interface DesktopPreReadyCommandLineReader { · 16 unmodified lines
17 readonly getSwitchValue: (switchName: string) => string;17 readonly getSwitchValue: (switchName: string) => string;
18}18}
19 19
20export function readCommandLineSwitchValue(20function readCommandLineSwitchValue(
21 commandLine: DesktopPreReadyCommandLineReader,21 commandLine: DesktopPreReadyCommandLineReader,
22 switchName: string,22 switchName: string,
23): string | null {23): string | null {