let collectionService: CollectionService;
let serverApi: AxiosInstance;
let axiosMock: MockAdapter;
- let webdavClient: any;
+ let keepWebdavClient: any;
let authService;
let actions;
beforeEach(() => {
serverApi = axios.create();
axiosMock = new MockAdapter(serverApi);
- webdavClient = {
+ keepWebdavClient = {
delete: jest.fn(),
upload: jest.fn(),
mkdir: jest.fn(),
progressFn: jest.fn(),
errorFn: jest.fn(),
} as any;
- collectionService = new CollectionService(serverApi, webdavClient, authService, actions);
+ collectionService = new CollectionService(serverApi, keepWebdavClient, authService, actions);
collectionService.update = jest.fn();
});
},
select: ['uuid', 'name', 'version', 'modified_at'],
}
- collectionService = new CollectionService(serverApi, webdavClient, authService, actions);
+ collectionService = new CollectionService(serverApi, keepWebdavClient, authService, actions);
await collectionService.update('uuid', data);
expect(serverApi.put).toHaveBeenCalledWith('/collections/uuid', expected);
});
await collectionService.uploadFiles(collectionUUID, files);
// then
- expect(webdavClient.upload).not.toHaveBeenCalled();
+ expect(keepWebdavClient.upload).not.toHaveBeenCalled();
});
it('should upload files', async () => {
await collectionService.uploadFiles(collectionUUID, files);
// then
- expect(webdavClient.upload).toHaveBeenCalledTimes(1);
- expect(webdavClient.upload.mock.calls[0][0]).toEqual("c=zzzzz-4zz18-0123456789abcde/test-file1");
+ expect(keepWebdavClient.upload).toHaveBeenCalledTimes(1);
+ expect(keepWebdavClient.upload.mock.calls[0][0]).toEqual("c=zzzzz-4zz18-0123456789abcde/test-file1");
});
it('should upload files with custom uplaod target', async () => {
await collectionService.uploadFiles(collectionUUID, files, undefined, customTarget);
// then
- expect(webdavClient.upload).toHaveBeenCalledTimes(1);
- expect(webdavClient.upload.mock.calls[0][0]).toEqual("c=zzzzz-4zz18-0123456789adddd/test-path/test-file1");
+ expect(keepWebdavClient.upload).toHaveBeenCalledTimes(1);
+ expect(keepWebdavClient.upload.mock.calls[0][0]).toEqual("c=zzzzz-4zz18-0123456789adddd/test-path/test-file1");
});
});