@asposecloud/aspose-tasks-cloud
Version:
Aspose.Tasks Cloud SDK for Node.js
132 lines (128 loc) • 7.51 kB
JavaScript
"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("putRecalculateProject function", () => {
it("should return response with code 200 and validation result", () => __awaiter(void 0, void 0, void 0, function* () {
const tasksApi = BaseTest.initializeTasksApi();
const fileName = "sample.mpp";
const localPath = BaseTest.localBaseTestDataFolder + fileName;
const remotePath = BaseTest.remoteBaseTestDataFolder;
const remoteFullPath = remotePath + "/" + fileName;
yield tasksApi.uploadFileToStorage(remoteFullPath, localPath);
const postTaskRequest = new model_1.PostTaskRequest();
postTaskRequest.name = fileName;
postTaskRequest.folder = remotePath;
postTaskRequest.taskName = "NewTaskName";
const postTaskResult = yield tasksApi.postTask(postTaskRequest);
chai_1.expect(postTaskResult.body.code).to.equal(201);
const taskUid = postTaskResult.body.taskItem.uid;
const getTaskRequest = new model_1.GetTaskRequest();
getTaskRequest.name = fileName;
getTaskRequest.folder = remotePath;
getTaskRequest.taskUid = taskUid;
const getTaskResult = yield tasksApi.getTask(getTaskRequest);
chai_1.expect(getTaskResult.body.code).to.equal(200);
chai_1.expect(getTaskResult.body.task).not.undefined.and.not.null;
const task = getTaskResult.body.task;
task.name = "New task Name";
task.actualStart = new Date(2000, 9, 20);
task.actualFinish = new Date(2000, 9, 9);
task.cost = 100;
const putTaskRequest = new model_1.PutTaskRequest();
putTaskRequest.task = task;
putTaskRequest.taskUid = taskUid;
putTaskRequest.name = fileName;
putTaskRequest.folder = remotePath;
putTaskRequest.recalculate = false;
const putTaskResult = yield tasksApi.putTask(putTaskRequest);
chai_1.expect(putTaskResult.body.code).to.equal(200);
const putRecalculateProjectRequest = new model_1.PutRecalculateProjectRequest();
putRecalculateProjectRequest.name = fileName;
putRecalculateProjectRequest.fileName = fileName;
putRecalculateProjectRequest.folder = remotePath;
putRecalculateProjectRequest.mode = model_1.CalculationMode.None;
putRecalculateProjectRequest.validate = true;
const putRecalculateProjectResult = yield tasksApi.putRecalculateProject(putRecalculateProjectRequest);
chai_1.expect(putRecalculateProjectResult.body.code).to.equal(200);
chai_1.expect(putRecalculateProjectResult.body.result.validationState).to.equal(model_1.ProjectValidationState.Valid);
}));
});
describe("putRecalculateProjectResourceFields function", () => {
it("should return response with code 200", () => __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.PutRecalculateProjectResourceFieldsRequest();
request.name = fileName;
request.folder = remotePath;
const result = yield tasksApi.putRecalculateProjectResourceFields(request);
chai_1.expect(result.response.statusCode).to.equal(200);
}));
});
describe("putRecalculateProjectUncompleteWorkToStartAfter function", () => {
it("should return response with code 200", () => __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.PutRecalculateProjectUncompleteWorkToStartAfterRequest();
request.name = fileName;
request.folder = remotePath;
request.after = new Date(2010, 9, 10);
const result = yield tasksApi.putRecalculateProjectUncompleteWorkToStartAfter(request);
chai_1.expect(result.response.statusCode).to.equal(200);
}));
});
describe("putRecalculateProjectWorkAsComplete function", () => {
it("should return response with code 200", () => __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.PutRecalculateProjectWorkAsCompleteRequest();
request.name = fileName;
request.folder = remotePath;
request.completeThrough = new Date(2010, 9, 10);
const result = yield tasksApi.putRecalculateProjectWorkAsComplete(request);
chai_1.expect(result.response.statusCode).to.equal(200);
}));
});
//# sourceMappingURL=recalculationTests.js.map