diff options
author | Devlin Junker <devlin.junker@gmail.com> | 2022-10-26 23:13:27 -0700 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2022-11-02 11:27:20 +0100 |
commit | 3bf3bc17ce2848bcb682e1c37ce36c11984a4d1c (patch) | |
tree | 5b25e5f344cbc15612f1a0c21e590d8dde0098a9 /tests | |
parent | 431236bbd84fbdcf130100c7d5f861e3d54c5542 (diff) |
fix tests with proper mocking
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/javascript/unit/OC.ts | 38 | ||||
-rw-r--r-- | tests/javascript/unit/components/Explore.spec.ts | 11 | ||||
-rw-r--r-- | tests/javascript/unit/setup.ts | 6 |
3 files changed, 47 insertions, 8 deletions
diff --git a/tests/javascript/unit/OC.ts b/tests/javascript/unit/OC.ts new file mode 100644 index 000000000..cbc7c642e --- /dev/null +++ b/tests/javascript/unit/OC.ts @@ -0,0 +1,38 @@ +export class OC { + + generateUrl(url: any) { + return '' + } + + imagePath(app: any, img: any) { + return '' + } + + linkToRemote(app: any) { + return '' + } + + getLanguage() { + return 'en-GB' + } + + getLocale() { + return 'en_GB' + } + + isUserAdmin() { + return false + } + + L10N = { + translate(app: any, text: any) { + return text + }, + + translatePlural(app: any, text: any) { + return text + }, + } + + config = {} +} diff --git a/tests/javascript/unit/components/Explore.spec.ts b/tests/javascript/unit/components/Explore.spec.ts index b0fe86a28..bd50fe592 100644 --- a/tests/javascript/unit/components/Explore.spec.ts +++ b/tests/javascript/unit/components/Explore.spec.ts @@ -1,18 +1,21 @@ - +import axios from '@nextcloud/axios' import { shallowMount } from '@vue/test-utils' import { store, localVue } from '../setupStore' -import axios from '@nextcloud/axios' import * as router from '@nextcloud/router' import Explore from 'Components/Explore.vue' +jest.mock('@nextcloud/axios') + describe('Explore.vue', () => { 'use strict' + + it('should initialize without showing AddFeed Component', () => { - axios.get = jest.fn().mockResolvedValue({ data: { } }) - (router as any).generateUrl = jest.fn().mockReturnedValue(''); + (axios as any).get.mockResolvedValue({ data: { } }) + (router as any).generateUrl = jest.fn().mockReturnValue(''); const wrapper = shallowMount(Explore, { localVue, store }) diff --git a/tests/javascript/unit/setup.ts b/tests/javascript/unit/setup.ts index ec9d61f8f..f3b734953 100644 --- a/tests/javascript/unit/setup.ts +++ b/tests/javascript/unit/setup.ts @@ -1,10 +1,8 @@ import { config } from '@vue/test-utils' // Note: This was copied from nextcloud/tasks repo -// import { OC } from './OC.js' - -// TODO: will this be used? -// global.OC = new OC() +import { OC } from './OC' +(global as any).OC = new OC() // Mock nextcloud translate functions config.mocks.$t = function(_app: any, string: any) { |