@asposecloud/aspose-tasks-cloud
Version:
Aspose.Tasks Cloud SDK for Node.js
160 lines (156 loc) • 7.71 kB
JavaScript
/*
* MIT License
* Copyright (c) 2019 Aspose Pty Ltd
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
require("mocha");
const BaseTest = require("../baseTest");
const storageFolder = BaseTest.remoteBaseTestDataFolder + "Storage";
describe("Storage folder operations", () => {
describe("Test for Create folder", () => {
it("should return response with code 200", () => __awaiter(void 0, void 0, void 0, function* () {
const tasksApi = BaseTest.initializeTasksApi();
const request = {
path: storageFolder + "/TestCreateFolder",
storageName: undefined,
};
return tasksApi.createFolder(request)
.then((result) => {
chai_1.expect(result.statusCode).to.equal(200);
});
}));
});
describe("Test for Delete folder", () => {
it("should return response with code 200", () => __awaiter(void 0, void 0, void 0, function* () {
const tasksApi = BaseTest.initializeTasksApi();
const folderName = storageFolder + "/TestDeleteFolder";
const request = {
path: folderName,
storageName: undefined,
};
return tasksApi.createFolder(request)
.then((result) => {
chai_1.expect(result.statusCode).to.equals(200);
const deleteRequset = {
path: folderName,
storageName: undefined,
recursive: undefined,
};
return tasksApi.deleteFolder(deleteRequset)
.then((result1) => {
chai_1.expect(result1.statusCode).to.equal(200);
});
});
}));
});
describe("Test for get file list of folder", () => {
it("should return response with code 200 and non empty list", () => __awaiter(void 0, void 0, void 0, function* () {
const tasksApi = BaseTest.initializeTasksApi();
const request = {
path: storageFolder,
storageName: undefined,
};
return tasksApi.getFilesList(request)
.then((result) => {
chai_1.expect(result.response.statusCode).to.equal(200);
chai_1.expect(result.body.value.length).to.be.greaterThan(0);
});
}));
});
describe("Test for copy folder", () => {
it("should return response with code 200 and new folder exists", () => __awaiter(void 0, void 0, void 0, function* () {
const tasksApi = BaseTest.initializeTasksApi();
const src = storageFolder + "/TestCopyFolderSrc";
const dest = storageFolder + "/TestCopyFolderDest";
const request = {
path: src,
storageName: undefined,
};
return tasksApi.createFolder(request)
.then((result) => {
chai_1.expect(result.statusCode).to.equal(200);
const copyFolderRequest = {
srcPath: src,
destPath: dest,
srcStorageName: undefined,
destStorageName: undefined,
};
return tasksApi.copyFolder(copyFolderRequest)
.then((result1) => {
chai_1.expect(result1.statusCode).to.equal(200);
const getFilesRequest = {
path: storageFolder,
storageName: undefined,
};
return tasksApi.getFilesList(getFilesRequest)
.then((result2) => {
chai_1.expect(result2.response.statusCode).to.equal(200);
chai_1.expect(result2.body.value.some((file) => file.path === "/" + dest + "/")).to.be.true;
});
});
});
}));
});
describe("Test for move folder", () => {
it("should return response with code 200 and new folder exists, but old one doesn't", () => __awaiter(void 0, void 0, void 0, function* () {
const tasksApi = BaseTest.initializeTasksApi();
const src = storageFolder + "/TestMoveFolderSrc";
const dest = storageFolder + "/TestMoveFolderDest";
const request = {
path: src,
storageName: undefined,
};
return tasksApi.createFolder(request)
.then((result) => {
chai_1.expect(result.statusCode).to.equal(200);
const moveFolderRequest = {
srcPath: src,
destPath: dest,
srcStorageName: undefined,
destStorageName: undefined,
};
return tasksApi.moveFolder(moveFolderRequest)
.then((result1) => {
chai_1.expect(result1.statusCode).to.equal(200);
const getFilesRequest = {
path: storageFolder,
storageName: undefined,
};
return tasksApi.getFilesList(getFilesRequest)
.then((result2) => {
chai_1.expect(result2.response.statusCode).to.equal(200);
chai_1.expect(result2.body.value.some((file) => file.path === "/" + dest + "/")).to.be.true;
chai_1.expect(result2.body.value.some((file) => file.path === "/" + src + "/")).to.be.false;
});
});
});
}));
});
});
//# sourceMappingURL=folderTests.js.map
;