diff options
Diffstat (limited to 'tests/javascript/unit/store/folder.spec.ts')
-rw-r--r-- | tests/javascript/unit/store/folder.spec.ts | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/javascript/unit/store/folder.spec.ts b/tests/javascript/unit/store/folder.spec.ts index eacfd18cb..8fd2ad34f 100644 --- a/tests/javascript/unit/store/folder.spec.ts +++ b/tests/javascript/unit/store/folder.spec.ts @@ -1,47 +1,47 @@ -import axios from '@nextcloud/axios' -import { generateUrl } from '@nextcloud/router' import { Folder } from '../../../../src/types/Folder' import { AppState } from '../../../../src/store' import { FOLDER_ACTION_TYPES, mutations, actions } from '../../../../src/store/folder' import { FOLDER_MUTATION_TYPES } from '../../../../src/types/MutationTypes' +import { FolderService } from '../../../../src/dataservices/folder.service' -jest.mock('@nextcloud/axios') jest.mock('@nextcloud/router') describe('folder.ts', () => { 'use strict' describe('actions', () => { - it('FETCH_FOLDERS should send GET and then commit folders returned to state', async () => { - (generateUrl as any).mockReturnValue(''); - (axios.get as any).mockResolvedValue({ data: { folders: [] } }) + it('FETCH_FOLDERS should call FolderService.fetchAllFolders and then commit folders returned to state', async () => { + FolderService.fetchAllFolders = jest.fn(); + (FolderService.fetchAllFolders as any).mockResolvedValue({ data: { folders: [] } }) const commit = jest.fn() await (actions[FOLDER_ACTION_TYPES.FETCH_FOLDERS] as any)({ commit }) - expect(axios.get).toBeCalled() + expect(FolderService.fetchAllFolders).toBeCalled() expect(commit).toBeCalled() }) - it('ADD_FOLDERS should send POST and then commit the folders returned to state', async () => { - (axios.post as any).mockResolvedValue({ data: { folders: [] } }) + it('ADD_FOLDERS should call FolderService.createFolder and then commit the folders returned to state', async () => { + FolderService.createFolder = jest.fn(); + (FolderService.createFolder as any).mockResolvedValue({ data: { folders: [] } }) const folder = {} as Folder const commit = jest.fn() await actions[FOLDER_ACTION_TYPES.ADD_FOLDERS]({ commit }, { folder }) - expect(axios.post).toBeCalled() + expect(FolderService.createFolder).toBeCalled() expect(commit).toBeCalled() }) - it('DELETE_FOLDER should send DELETE and then commit deleted folder to state', async () => { - (axios.delete as any).mockResolvedValue() + it('DELETE_FOLDER should call FolderService.deleteFolder and then commit deleted folder to state', async () => { + FolderService.deleteFolder = jest.fn(); + (FolderService.deleteFolder as any).mockResolvedValue() const folder = {} as Folder const commit = jest.fn() await actions[FOLDER_ACTION_TYPES.DELETE_FOLDER]({ commit }, { folder }) - expect(axios.delete).toBeCalled() + expect(FolderService.deleteFolder).toBeCalled() expect(commit).toBeCalled() }) }) |