UNPKG

@asposecloud/aspose-tasks-cloud

Version:
172 lines (168 loc) 9.43 kB
"use strict"; /* * 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 model_1 = require("../src/model/model"); const BaseTest = require("./baseTest"); describe("getDocumentProperties function", () => { it("should return response with code 200 and correct data", () => __awaiter(void 0, void 0, void 0, function* () { const tasksApi = BaseTest.initializeTasksApi(); const fileName = "Home_move_plan.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const request = new model_1.GetDocumentPropertiesRequest(); request.name = fileName; request.folder = remotePath; const result = yield tasksApi.getDocumentProperties(request); chai_1.expect(result.response.statusCode).to.equal(200); chai_1.expect(result.body.properties.list.length).to.equal(63); chai_1.expect(result.body.properties.list[0].name).to.equal("Title"); chai_1.expect(result.body.properties.list[0].value).to.equal("Home Move"); })); }); describe("getDocumentProperty function", () => { it("should return response with code 200 and correct data", () => __awaiter(void 0, void 0, void 0, function* () { const tasksApi = BaseTest.initializeTasksApi(); const fileName = "Home_move_plan.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const request = new model_1.GetDocumentPropertyRequest(); request.name = fileName; request.folder = remotePath; request.propertyName = "Title"; const result = yield tasksApi.getDocumentProperty(request); chai_1.expect(result.response.statusCode).to.equal(200); chai_1.expect(result.body.property).is.not.null.and.not.undefined; chai_1.expect(result.body.property.name).to.equal("Title"); chai_1.expect(result.body.property.value).to.equal("Home Move"); })); }); describe("putDocumentProperty function", () => { it("should return response with code 200 and correct data", () => __awaiter(void 0, void 0, void 0, function* () { const tasksApi = BaseTest.initializeTasksApi(); const fileName = "Home_move_plan.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const property = new model_1.DocumentProperty(); property.name = "Title"; property.value = "New title value"; const request1 = new model_1.PutDocumentPropertyRequest(); request1.name = fileName; request1.folder = remotePath; request1.propertyName = "Title"; request1.property = property; yield tasksApi.putDocumentProperty(request1); const request2 = new model_1.GetDocumentPropertyRequest(); request2.name = fileName; request2.folder = remotePath; request2.propertyName = "Title"; const result = yield tasksApi.getDocumentProperty(request2); chai_1.expect(result.body.property.value).to.equal("New title value"); })); it("should return response with code 200 and ignore changes of nonexistent property", () => __awaiter(void 0, void 0, void 0, function* () { const tasksApi = BaseTest.initializeTasksApi(); const fileName = "Home_move_plan.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const property = new model_1.DocumentProperty(); property.name = "new property"; property.value = "new property value"; const request1 = new model_1.PutDocumentPropertyRequest(); request1.name = fileName; request1.folder = remotePath; request1.propertyName = "new property"; request1.property = property; yield tasksApi.putDocumentProperty(request1); const request2 = new model_1.GetDocumentPropertyRequest(); request2.name = fileName; request2.folder = remotePath; request2.propertyName = "new property"; const result = yield tasksApi.getDocumentProperty(request2); chai_1.expect(result.body.property).is.null; })); }); describe("postDocumentProperty function", () => { it("should return response with code 200 and correct data", () => __awaiter(void 0, void 0, void 0, function* () { const tasksApi = BaseTest.initializeTasksApi(); const fileName = "Home_move_plan.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const property = new model_1.DocumentProperty(); property.name = "Title"; property.value = "New title value"; const request1 = new model_1.PostDocumentPropertyRequest(); request1.name = fileName; request1.folder = remotePath; request1.propertyName = "Title"; request1.property = property; yield tasksApi.postDocumentProperty(request1); const request2 = new model_1.GetDocumentPropertyRequest(); request2.name = fileName; request2.folder = remotePath; request2.propertyName = "Title"; const result = yield tasksApi.getDocumentProperty(request2); chai_1.expect(result.body.property.value).to.equal("New title value"); })); it("should return response with code 200 and ignore changes of nonexistent property", () => __awaiter(void 0, void 0, void 0, function* () { const tasksApi = BaseTest.initializeTasksApi(); const fileName = "Home_move_plan.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const property = new model_1.DocumentProperty(); property.name = "new property"; property.value = "new property value"; const request1 = new model_1.PostDocumentPropertyRequest(); request1.name = fileName; request1.folder = remotePath; request1.propertyName = "new property"; request1.property = property; yield tasksApi.postDocumentProperty(request1); const request2 = new model_1.GetDocumentPropertyRequest(); request2.name = fileName; request2.folder = remotePath; request2.propertyName = "new property"; const result = yield tasksApi.getDocumentProperty(request2); chai_1.expect(result.body.property).is.null; })); }); //# sourceMappingURL=documentPropertiesTests.js.map