1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-06 04:00:05 +00:00

fix: move function, test: added test for folder operations

This commit is contained in:
Mihajlo Medjedovic
2021-01-06 16:32:57 +01:00
parent 246b855c76
commit ecfc1a4bf8
2 changed files with 65 additions and 9 deletions

View File

@@ -1328,20 +1328,22 @@ export class SASViyaApiClient {
targetParentFolder,
accessToken
)
targetFolderName = targetFolderDetails ? sourceFolderName : targetFolderName
if (!targetFolderDetails) {
let targetParentFolderArr = targetParentFolder.split('/')
targetParentFolderArr.splice(targetParentFolderArr.length - 1, 1)
targetParentFolder = targetParentFolderArr.join('/')
} else {
targetFolderName = sourceFolderName
}
// checks if 'sourceFolder' is already a URI
const sourceFolderUri = isUri(sourceFolder)
? sourceFolder
: await this.getFolderUri(sourceFolder, accessToken)
const sourceFolderUri = await this.getFolderUri(sourceFolder, accessToken)
// checks if 'targetParentFolder' is already a URI
const targetParentFolderUri = isUri(targetParentFolder)
? targetParentFolder
: await this.getFolderUri(targetParentFolder, accessToken)
const targetParentFolderUri = await this.getFolderUri(targetParentFolder, accessToken)
const sourceFolderId = sourceFolderUri?.split('/').pop()
const url = sourceFolderUri
const requestInfo = {
method: 'PATCH',
@@ -1357,7 +1359,7 @@ export class SASViyaApiClient {
}
const { result: folder } = await this.request<Folder>(
`${this.serverUrl}${url}`,
`${this.serverUrl}${sourceFolderUri}`,
requestInfo
).catch((err) => {
if (err.code && err.code === 'ENOTFOUND') {