Merge branch 'INDA-330-pii-update' into 'main'
[ProtonMail-WebClient.git] / packages / account / securityCheckup / helpers / getSource.test.ts
blobdea5db3f516a6a1aae950417e8c25ba376d0c7dd
1 import { APPS } from '@proton/shared/lib/constants';
3 import getSource from './getSource';
5 describe('getSource', () => {
6     test('returns undefined for empty pathname', () => {
7         const result = getSource({ pathname: '', search: new URLSearchParams() });
8         expect(result).toBe(undefined);
9     });
11     test('returns undefined for empty search params', () => {
12         const result = getSource({ pathname: '', search: new URLSearchParams() });
13         expect(result).toBe(undefined);
14     });
16     describe('email source', () => {
17         test(`returns 'email_danger' source if path is 'safety-review/source/email-danger'`, () => {
18             const pathname = '/u/0/safety-review/source/email-danger';
20             const result = getSource({ pathname, search: new URLSearchParams() });
22             expect(result).toBe('email_danger');
23         });
25         test(`returns 'email_warning' source if path is 'safety-review/source/email-warning'`, () => {
26             const pathname = '/u/0/safety-review/source/email-warning';
28             const result = getSource({ pathname, search: new URLSearchParams() });
30             expect(result).toBe('email_warning');
31         });
33         test(`returns 'email_info' source if path is 'safety-review/source/email-info'`, () => {
34             const pathname = '/u/0/safety-review/source/email-info';
36             const result = getSource({ pathname, search: new URLSearchParams() });
38             expect(result).toBe('email_info');
39         });
40     });
42     describe('dropdown source', () => {
43         test(`returns 'user_dropdown_account' source if source query param is 'user_dropdown' and appname is 'proton-account'`, () => {
44             const pathname = '/u/0/safety-review';
45             const search = new URLSearchParams({ source: 'user_dropdown', appname: APPS.PROTONACCOUNT });
47             const result = getSource({ pathname, search });
49             expect(result).toBe('user_dropdown_account');
50         });
52         test(`returns 'user_dropdown_vpn_settings' source if source query param is 'user_dropdown' and appname is 'proton-vpn-settings'`, () => {
53             const pathname = '/u/0/safety-review';
54             const search = new URLSearchParams({ source: 'user_dropdown', appname: APPS.PROTONVPN_SETTINGS });
56             const result = getSource({ pathname, search });
58             expect(result).toBe('user_dropdown_vpn_settings');
59         });
61         test(`returns 'user_dropdown_mail' source if source query param is 'user_dropdown' and appname is 'proton-mail'`, () => {
62             const pathname = '/u/0/safety-review';
63             const search = new URLSearchParams({ source: 'user_dropdown', appname: APPS.PROTONMAIL });
65             const result = getSource({ pathname, search });
67             expect(result).toBe('user_dropdown_mail');
68         });
70         test(`returns 'user_dropdown_calendar' source if source query param is 'user_dropdown' and appname is 'proton-calendar'`, () => {
71             const pathname = '/u/0/safety-review';
72             const search = new URLSearchParams({ source: 'user_dropdown', appname: APPS.PROTONCALENDAR });
74             const result = getSource({ pathname, search });
76             expect(result).toBe('user_dropdown_calendar');
77         });
79         test(`returns 'user_dropdown_drive' source if source query param is 'user_dropdown' and appname is 'proton-drive'`, () => {
80             const pathname = '/u/0/safety-review';
81             const search = new URLSearchParams({ source: 'user_dropdown', appname: APPS.PROTONDRIVE });
83             const result = getSource({ pathname, search });
85             expect(result).toBe('user_dropdown_drive');
86         });
88         test(`returns 'user_dropdown_docs' source if source query param is 'user_dropdown' and appname is 'proton-docs'`, () => {
89             const pathname = '/u/0/safety-review';
90             const search = new URLSearchParams({ source: 'user_dropdown', appname: APPS.PROTONDOCS });
92             const result = getSource({ pathname, search });
94             expect(result).toBe('user_dropdown_docs');
95         });
96     });
98     describe('recovery settings', () => {
99         test(`returns 'recovery_settings' source if source query param is 'recovery_settings'`, () => {
100             const pathname = '/u/0/safety-review';
101             const search = new URLSearchParams('?source=recovery_settings');
103             const result = getSource({ pathname, search });
105             expect(result).toBe('recovery_settings');
106         });
107     });