Remove client-side isLoggedIn value
[ProtonMail-WebClient.git] / packages / shared / test / desktop / getLatestRelease.spec.ts
blobf997937baf9a09a1439839082d759d20df658494
1 import { RELEASE_CATEGORIES } from '@proton/shared/lib/constants';
2 import { type DesktopVersion } from '@proton/shared/lib/desktop/DesktopVersion';
4 import { getLatestRelease } from '../../lib/desktop/getLatestRelease';
6 describe('getLatestRelease', () => {
7     describe('when alpha is the latest', () => {
8         const releaseList = [
9             { Version: '1.2.0', CategoryName: RELEASE_CATEGORIES.ALPHA },
10             { Version: '1.1.0', CategoryName: RELEASE_CATEGORIES.EARLY_ACCESS },
11             { Version: '1.0.0', CategoryName: RELEASE_CATEGORIES.STABLE },
12             { Version: '0.9.0', CategoryName: RELEASE_CATEGORIES.STABLE },
13             { Version: '0.0.1', CategoryName: RELEASE_CATEGORIES.STABLE },
14         ] as DesktopVersion[];
16         it('should get alpha release, when local is alpha', () => {
17             expect(getLatestRelease('alpha', releaseList)).toEqual(
18                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.ALPHA })
19             );
20         });
21         it('should get beta release, when local is beta', () => {
22             expect(getLatestRelease('beta', releaseList)).toEqual(
23                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.EARLY_ACCESS })
24             );
25         });
26         it('should get stable release, when local is default', () => {
27             expect(getLatestRelease('default', releaseList)).toEqual(
28                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
29             );
30         });
31         it('should get stable release, when local is undefined', () => {
32             expect(getLatestRelease(undefined, releaseList)).toEqual(
33                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
34             );
35         });
36     });
38     describe('when beta is the latest', () => {
39         const releaseList = [
40             { Version: '1.1.0', CategoryName: RELEASE_CATEGORIES.EARLY_ACCESS },
41             { Version: '1.0.0', CategoryName: RELEASE_CATEGORIES.STABLE },
42             { Version: '0.9.0', CategoryName: RELEASE_CATEGORIES.STABLE },
43             { Version: '0.0.1', CategoryName: RELEASE_CATEGORIES.STABLE },
44         ] as DesktopVersion[];
46         it('should get beta release, when local is alpha', () => {
47             expect(getLatestRelease('alpha', releaseList)).toEqual(
48                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.EARLY_ACCESS })
49             );
50         });
51         it('should get beta release, when local is beta', () => {
52             expect(getLatestRelease('beta', releaseList)).toEqual(
53                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.EARLY_ACCESS })
54             );
55         });
56         it('should get stable release, when local is default', () => {
57             expect(getLatestRelease('default', releaseList)).toEqual(
58                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
59             );
60         });
61         it('should get stable release, when local is undefined', () => {
62             expect(getLatestRelease(undefined, releaseList)).toEqual(
63                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
64             );
65         });
66     });
68     describe('when stable is the latest', () => {
69         const releaseList = [
70             { Version: '0.9.0', CategoryName: RELEASE_CATEGORIES.STABLE },
71             { Version: '0.0.1', CategoryName: RELEASE_CATEGORIES.STABLE },
72             { Version: '1.0.0', CategoryName: RELEASE_CATEGORIES.STABLE },
73         ] as DesktopVersion[];
75         it('should get stable release, when local is alpha', () => {
76             expect(getLatestRelease('alpha', releaseList)).toEqual(
77                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
78             );
79         });
80         it('should get stable release, when local is beta', () => {
81             expect(getLatestRelease('beta', releaseList)).toEqual(
82                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
83             );
84         });
85         it('should get stable release, when local is default', () => {
86             expect(getLatestRelease('default', releaseList)).toEqual(
87                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
88             );
89         });
90         it('should get stable release, when local is undefined', () => {
91             expect(getLatestRelease(undefined, releaseList)).toEqual(
92                 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
93             );
94         });
96         it('should get highest version', () => {
97             expect(getLatestRelease('default', releaseList)).toEqual(jasmine.objectContaining({ Version: '1.0.0' }));
98         });
99     });