Browse Source

fix(tests): Add mock for `window._oc_webroot`

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
tags/v29.0.0beta6
Ferdinand Thiessen 1 month ago
parent
commit
fef9fb3bc0
No account linked to committer's email address

+ 6
- 0
apps/files/src/actions/downloadAction.spec.ts View File

@@ -28,6 +28,12 @@ const view = {
name: 'Files',
} as View

// Mock webroot variable
beforeAll(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any)._oc_webroot = ''
})

describe('Download action conditions tests', () => {
test('Default values', () => {
expect(action).toBeInstanceOf(FileAction)

+ 6
- 0
apps/files/src/actions/editLocallyAction.spec.ts View File

@@ -30,6 +30,12 @@ const view = {
name: 'Files',
} as View

// Mock webroot variable
beforeAll(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any)._oc_webroot = ''
})

describe('Edit locally action conditions tests', () => {
test('Default values', () => {
expect(action).toBeInstanceOf(FileAction)

+ 6
- 0
apps/files/src/actions/favoriteAction.spec.ts View File

@@ -41,6 +41,12 @@ global.window.OC = {
TAG_FAVORITE: '_$!<Favorite>!$_',
}

// Mock webroot variable
beforeAll(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any)._oc_webroot = ''
})

describe('Favorite action conditions tests', () => {
test('Default values', () => {
const file = new File({

+ 6
- 0
apps/files_sharing/src/actions/acceptShareAction.spec.ts View File

@@ -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({

+ 6
- 0
apps/files_sharing/src/actions/rejectShareAction.spec.ts View File

@@ -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({

+ 6
- 0
apps/files_sharing/src/actions/restoreShareAction.spec.ts View File

@@ -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({

+ 6
- 0
apps/files_sharing/src/services/SharingService.spec.ts View File

@@ -33,6 +33,12 @@ global.window.OC = {
TAG_FAVORITE: '_$!<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<any> => {

+ 6
- 0
core/js/tests/specs/l10nSpec.js View File

@@ -13,10 +13,15 @@ describe('OC.L10N tests', function() {

beforeEach(function() {
window._oc_appswebroots[TEST_APP] = OC.getRootPath() + '/apps3/jsunittestapp';

window.OC = window.OC ?? {}
window.OC.appswebroots = window.OC.appswebroots || {}
window.OC.appswebroots[TEST_APP] = OC.getRootPath() + '/apps3/jsunittestapp'
});
afterEach(function() {
OC.L10N._unregister(TEST_APP);
delete window._oc_appswebroots[TEST_APP];
delete window.OC.appswebroots[TEST_APP];
});

describe('text translation', function() {
@@ -121,6 +126,7 @@ describe('OC.L10N tests', function() {
expect(callbackStub.notCalled).toEqual(true);
var req = fakeServer.requests[0];

console.warn('fff-', window.OC.appswebroots)
loading
.then(promiseStub)
.then(function() {

Loading…
Cancel
Save