1 import { getAppHref } from '../../lib/apps/helper';
2 import { APPS } from '../../lib/constants';
5 hostname: 'calendar.protonmail.com',
9 describe('sso app href', () => {
10 it('should produce links relative to the current second level domain', () => {
11 expect(getAppHref('/', APPS.PROTONACCOUNT, undefined, location)).toBe(`https://account.protonmail.com`);
14 it('should produce links relative to localhost', () => {
16 hostname: 'localhost',
20 expect(getAppHref('/', APPS.PROTONACCOUNT, undefined, location)).toBe(`http://account.localhost`);
23 it('should produce links relative to the current top domain', () => {
25 hostname: 'protonmail.com',
29 expect(getAppHref('/', APPS.PROTONACCOUNT, undefined, location)).toBe(`https://account.protonmail.com`);
32 it('should produce links relative to the current domain, with a local id', () => {
33 expect(getAppHref('/', APPS.PROTONACCOUNT, 1, location)).toBe(`https://account.protonmail.com/u/1`);
36 it('should produce links to other apps', () => {
37 expect(getAppHref('/', APPS.PROTONCALENDAR, 2, location)).toBe(`https://calendar.protonmail.com/u/2`);
40 it('should produce links to other apps with another location', () => {
46 expect(getAppHref('/', APPS.PROTONCALENDAR, 2, location)).toBe(`https://calendar.test.com/u/2`);
49 it('should produce links respecting the port', () => {
55 expect(getAppHref('/', APPS.PROTONCALENDAR, 2, location)).toBe(`https://calendar.test.com:4443/u/2`);
58 it('should produce links to other apps with another location', () => {
64 expect(getAppHref('/', APPS.PROTONCALENDAR, 2, location)).toBe(`https://calendar.test.com/u/2`);
67 it('should override protonvpn hostname', () => {
69 hostname: 'account.protonvpn.com',
73 expect(getAppHref('/', APPS.PROTONCALENDAR, 2, location)).toBe(`https://calendar.proton.me/u/2`);
76 it('should produce links stripping previous local id basenames', () => {
78 hostname: 'account.protonmail.com',
82 expect(getAppHref('/u/0/mail', APPS.PROTONACCOUNT, 2, location)).toBe(
83 `https://account.protonmail.com/u/2/mail`
85 expect(getAppHref('/u/0/mail', APPS.PROTONACCOUNT, 0, location)).toBe(
86 `https://account.protonmail.com/u/0/mail`