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', () => {
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 })
21 it('should get beta release, when local is beta', () => {
22 expect(getLatestRelease('beta', releaseList)).toEqual(
23 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.EARLY_ACCESS })
26 it('should get stable release, when local is default', () => {
27 expect(getLatestRelease('default', releaseList)).toEqual(
28 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
31 it('should get stable release, when local is undefined', () => {
32 expect(getLatestRelease(undefined, releaseList)).toEqual(
33 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
38 describe('when beta is the latest', () => {
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 })
51 it('should get beta release, when local is beta', () => {
52 expect(getLatestRelease('beta', releaseList)).toEqual(
53 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.EARLY_ACCESS })
56 it('should get stable release, when local is default', () => {
57 expect(getLatestRelease('default', releaseList)).toEqual(
58 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
61 it('should get stable release, when local is undefined', () => {
62 expect(getLatestRelease(undefined, releaseList)).toEqual(
63 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
68 describe('when stable is the latest', () => {
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 })
80 it('should get stable release, when local is beta', () => {
81 expect(getLatestRelease('beta', releaseList)).toEqual(
82 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
85 it('should get stable release, when local is default', () => {
86 expect(getLatestRelease('default', releaseList)).toEqual(
87 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
90 it('should get stable release, when local is undefined', () => {
91 expect(getLatestRelease(undefined, releaseList)).toEqual(
92 jasmine.objectContaining({ CategoryName: RELEASE_CATEGORIES.STABLE })
96 it('should get highest version', () => {
97 expect(getLatestRelease('default', releaseList)).toEqual(jasmine.objectContaining({ Version: '1.0.0' }));