1 import { BridgeOriginProvider } from './BridgeOriginProvider'
3 describe('BridgeOriginProvider', () => {
4 const setLocation = (hostname: string) => {
5 Object.defineProperty(window, 'location', {
7 origin: `https://${hostname}`,
16 describe('GetSafeOrigin', () => {
17 it('should return root origin', () => {
18 setLocation('docs.proton.local')
20 expect(BridgeOriginProvider.GetEditorOrigin()).toEqual('https://docs-editor.proton.local')
21 expect(BridgeOriginProvider.GetClientOrigin()).toEqual('https://docs.proton.local')
24 it('should return safe origin with remote domain', () => {
25 setLocation('docs.proton.me')
27 expect(BridgeOriginProvider.GetEditorOrigin()).toEqual('https://docs-editor.proton.me')
28 expect(BridgeOriginProvider.GetClientOrigin()).toEqual('https://docs.proton.me')
31 it('should return safe origin with nested domain', () => {
32 setLocation('docs.darwin.proton.black')
34 expect(BridgeOriginProvider.GetEditorOrigin()).toEqual('https://docs-editor.darwin.proton.black')
35 expect(BridgeOriginProvider.GetClientOrigin()).toEqual('https://docs.darwin.proton.black')