Merge branch 'docs-header-fix' into 'main'
[ProtonMail-WebClient.git] / packages / shared / test / api / headers.ts
blobb1367093f52024b7cab8f9f8c3c5038303a23cfb
1 import { getClientID } from '../../lib/apps/helper';
2 import type { APP_NAMES } from '../../lib/constants';
3 import { APPS } from '../../lib/constants';
4 import { getAppVersionHeaders } from '../../lib/fetch/headers';
6 describe('app version headers', () => {
7     it('should return new app headers', () => {
8         const test = (app: APP_NAMES, version: string, expectation: string) => {
9             expect(getAppVersionHeaders(getClientID(app), version)).toEqual({ 'x-pm-appversion': expectation });
10         };
12         for (const { app, version, expectation } of [
13             {
14                 app: APPS.PROTONMAIL,
15                 version: '4.999.999',
16                 expectation: 'web-mail@4.999.999',
17             },
18             {
19                 app: APPS.PROTONMAIL,
20                 version: '4.14.6',
21                 expectation: 'web-mail@4.14.6',
22             },
23             {
24                 app: APPS.PROTONCALENDAR,
25                 version: '4.0.1',
26                 expectation: 'web-calendar@4.0.1',
27             },
28             {
29                 app: APPS.PROTONVPN_SETTINGS,
30                 version: '4.999.999',
31                 expectation: 'web-vpn-settings@4.999.999',
32             },
33             {
34                 app: APPS.PROTONVERIFICATION,
35                 version: '4.1.0',
36                 expectation: 'web-verify@4.1.0',
37             },
38             {
39                 app: APPS.PROTONADMIN,
40                 version: '4.12.12',
41                 expectation: 'web-admin@4.12.12',
42             },
43         ]) {
44             test(app, version, expectation);
45         }
46     });
47 });