+ it('should batch move files within collection', async () => {
+ serverApi.put = jest.fn(() => Promise.resolve({ data: {} }));
+ // given
+ const filePaths: string[] = ['/one', '/two', '/subpath/subfile', 'barefile.txt'];
+ const srcCollectionUUID = 'zzzzz-4zz18-5o5tg0l9a57gxxx';
+ const srcCollectionPdh = '8cd9ce1dfa21c635b620b1bfee7aaa08+180';
+
+ const destinationPath = '/destinationPath';
+
+ // when
+ await collectionService.moveFiles(srcCollectionUUID, srcCollectionPdh, filePaths, srcCollectionUUID, destinationPath);
+
+ // then
+ expect(serverApi.put).toHaveBeenCalledTimes(1);
+ // Verify copy
+ expect(serverApi.put).toHaveBeenCalledWith(
+ `/collections/${srcCollectionUUID}`, {
+ collection: {
+ preserve_version: true
+ },
+ replace_files: {
+ [`${destinationPath}/one`]: `${srcCollectionPdh}/one`,
+ ['/one']: '',
+ [`${destinationPath}/two`]: `${srcCollectionPdh}/two`,
+ ['/two']: '',
+ [`${destinationPath}/subfile`]: `${srcCollectionPdh}/subpath/subfile`,
+ ['/subpath/subfile']: '',
+ [`${destinationPath}/barefile.txt`]: `${srcCollectionPdh}/barefile.txt`,
+ ['/barefile.txt']: '',
+ },
+ }
+ );
+ });
+