From fef9fb3bc0a93b94ca87968246fbac69c4590e2f Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 23 Mar 2024 19:36:18 +0100 Subject: fix(tests): Add mock for `window._oc_webroot` Signed-off-by: Ferdinand Thiessen --- apps/files_sharing/src/actions/acceptShareAction.spec.ts | 6 ++++++ apps/files_sharing/src/actions/rejectShareAction.spec.ts | 6 ++++++ apps/files_sharing/src/actions/restoreShareAction.spec.ts | 6 ++++++ apps/files_sharing/src/services/SharingService.spec.ts | 6 ++++++ 4 files changed, 24 insertions(+) (limited to 'apps/files_sharing/src') diff --git a/apps/files_sharing/src/actions/acceptShareAction.spec.ts b/apps/files_sharing/src/actions/acceptShareAction.spec.ts index b87cbef6a1c..0fae52c2103 100644 --- a/apps/files_sharing/src/actions/acceptShareAction.spec.ts +++ b/apps/files_sharing/src/actions/acceptShareAction.spec.ts @@ -36,6 +36,12 @@ const pendingShareView = { name: 'Pending shares', } as View +// Mock webroot variable +beforeAll(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (window as any)._oc_webroot = '' +}) + describe('Accept share action conditions tests', () => { test('Default values', () => { const file = new File({ diff --git a/apps/files_sharing/src/actions/rejectShareAction.spec.ts b/apps/files_sharing/src/actions/rejectShareAction.spec.ts index 292aec4c630..80c142052f9 100644 --- a/apps/files_sharing/src/actions/rejectShareAction.spec.ts +++ b/apps/files_sharing/src/actions/rejectShareAction.spec.ts @@ -36,6 +36,12 @@ const pendingShareView = { name: 'Pending shares', } as View +// Mock webroot variable +beforeAll(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (window as any)._oc_webroot = '' +}) + describe('Reject share action conditions tests', () => { test('Default values', () => { const file = new File({ diff --git a/apps/files_sharing/src/actions/restoreShareAction.spec.ts b/apps/files_sharing/src/actions/restoreShareAction.spec.ts index 44460a62495..f39694ac730 100644 --- a/apps/files_sharing/src/actions/restoreShareAction.spec.ts +++ b/apps/files_sharing/src/actions/restoreShareAction.spec.ts @@ -36,6 +36,12 @@ const deletedShareView = { name: 'Deleted shares', } as View +// Mock webroot variable +beforeAll(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (window as any)._oc_webroot = '' +}) + describe('Restore share action conditions tests', () => { test('Default values', () => { const file = new File({ diff --git a/apps/files_sharing/src/services/SharingService.spec.ts b/apps/files_sharing/src/services/SharingService.spec.ts index db9cb81e348..79b91c9826f 100644 --- a/apps/files_sharing/src/services/SharingService.spec.ts +++ b/apps/files_sharing/src/services/SharingService.spec.ts @@ -33,6 +33,12 @@ global.window.OC = { TAG_FAVORITE: '_$!!$_', } +// Mock webroot variable +beforeAll(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (window as any)._oc_webroot = '' +}) + describe('SharingService methods definitions', () => { beforeAll(() => { jest.spyOn(axios, 'get').mockImplementation(async (): Promise => { -- cgit v1.2.3