Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / shared / test / squirrel / squirrel.IGNORE.ts
blob1b19ba44d43987387cd00888cf0576c883e042d8
1 import * as electronModule from 'electron';
3 import { parseInstallArguments } from '@proton/shared/lib/squirrel/squirrel';
5 describe('squirrel', () => {
6     beforeEach(() => {
7         spyOnAllFunctions(electronModule);
8     });
10     describe('install arguments', () => {
11         it('should correctly parse want desktop shortcut', () => {
12             expect(
13                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--desktop-shortcut', '0'])
14                     .wantDesktopShortcut
15             ).toBe(false);
16             expect(
17                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--desktop-shortcut', '1'])
18                     .wantDesktopShortcut
19             ).toBe(true);
20             expect(
21                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--desktop-shortcut=0'])
22                     .wantDesktopShortcut
23             ).toBe(false);
24             expect(
25                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--desktop-shortcut=1'])
26                     .wantDesktopShortcut
27             ).toBe(true);
28             expect(
29                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op']).wantDesktopShortcut
30             ).toBe(true);
31         });
32         it('should correctly parse source', () => {
33             expect(
34                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op']).source
35             ).toBeUndefined();
36             expect(
37                 parseInstallArguments([
38                     '--squirrel-install',
39                     '0.0.1',
40                     '--silent',
41                     '--no-op',
42                     '--source',
43                     'fromInstaller',
44                 ]).source
45             ).toBe('fromInstaller');
46             expect(
47                 parseInstallArguments([
48                     '--squirrel-install',
49                     '0.0.1',
50                     '--silent',
51                     '--no-op',
52                     '--source',
53                     `"fromInstaller"`,
54                 ]).source
55             ).toBe('"fromInstaller"');
56             expect(
57                 parseInstallArguments([
58                     '--squirrel-install',
59                     '0.0.1',
60                     '--silent',
61                     '--no-op',
62                     '--source',
63                     `'fromInstaller'`,
64                 ]).source
65             ).toBe("'fromInstaller'");
66             expect(
67                 parseInstallArguments([
68                     '--squirrel-install',
69                     '0.0.1',
70                     '--silent',
71                     '--no-op',
72                     '--source',
73                     'from',
74                     'Installer',
75                 ]).source
76             ).toBe('from');
77             expect(
78                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--source=fromInstaller'])
79                     .source
80             ).toBe('fromInstaller');
81         });
82         it('should correctly parse is silent', () => {
83             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '-s', '--no-op']).isSilent).toBe(true);
84             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op']).isSilent).toBe(true);
85             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '1', '--no-op']).isSilent).toBe(
86                 true
87             );
88             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--silent=1', '--no-op']).isSilent).toBe(true);
89             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '0', '--no-op']).isSilent).toBe(
90                 false
91             );
92             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--silent=0', '--no-op']).isSilent).toBe(
93                 false
94             );
95             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--no-op']).isSilent).toBe(false);
96         });
97         it('should correctly parse is auto launch', () => {
98             expect(
99                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--auto-launch'])
100                     .isAutoLaunch
101             ).toBe(true);
102             expect(
103                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--auto-launch', '1'])
104                     .isAutoLaunch
105             ).toBe(true);
106             expect(
107                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--auto-launch=1'])
108                     .isAutoLaunch
109             ).toBe(true);
110             expect(
111                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op', '--source=fromInstaller'])
112                     .isAutoLaunch
113             ).toBe(true);
115             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '--no-op']).isAutoLaunch).toBe(
116                 true
117             );
118             expect(
119                 parseInstallArguments(['--squirrel-install', '0.0.1', '--silent', '1', '--no-op']).isAutoLaunch
120             ).toBe(true);
121             expect(parseInstallArguments(['--squirrel-install', '0.0.1', '--silent=1', '--no-op']).isAutoLaunch).toBe(
122                 true
123             );
124         });
125     });