UNPKG

@asposecloud/aspose-tasks-cloud

Version:
140 lines (136 loc) 8 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("getTaskRecurringInfo 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 = "sample.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const request = new model_1.GetTaskRecurringInfoRequest(); request.name = fileName; request.folder = remotePath; request.taskUid = 6; const result = yield tasksApi.getTaskRecurringInfo(request); chai_1.expect(result.response.statusCode).to.equal(200); chai_1.expect(result.body.recurringInfo).is.not.undefined.and.not.null; const entity = result.body.recurringInfo; chai_1.expect(entity.occurrences).to.equal(2); chai_1.expect(entity.recurrencePattern).to.equal(model_1.RecurrencePattern.Monthly); chai_1.expect(entity.useEndDate).to.equal(true); chai_1.expect(entity.monthlyUseOrdinalDay).to.equal(false); chai_1.expect(entity.monthlyDay).to.equal(1); chai_1.expect(entity.weeklyDays).to.equal(model_1.WeekDayType.None); chai_1.expect(entity.yearlyOrdinalNumber).to.equal(model_1.OrdinalNumber.Second); })); }); describe("putTaskRecurringInfo 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 = "sample.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const getRequest = new model_1.GetTaskRecurringInfoRequest(); getRequest.name = fileName; getRequest.folder = remotePath; getRequest.taskUid = 6; let getResult = yield tasksApi.getTaskRecurringInfo(getRequest); chai_1.expect(getResult.response.statusCode).to.equal(200); chai_1.expect(getResult.body.recurringInfo).is.not.undefined.and.not.null; const recurringInfo = getResult.body.recurringInfo; recurringInfo.occurrences = 10; const putRequest = new model_1.PutTaskRecurringInfoRequest(); putRequest.name = fileName; putRequest.folder = remotePath; putRequest.taskUid = 6; putRequest.recurringInfo = recurringInfo; const putResult = yield tasksApi.putTaskRecurringInfo(putRequest); chai_1.expect(putResult.response.statusCode).to.equal(200); getResult = yield tasksApi.getTaskRecurringInfo(getRequest); const entity = getResult.body.recurringInfo; chai_1.expect(entity.occurrences).to.equal(10); chai_1.expect(entity.recurrencePattern).to.equal(model_1.RecurrencePattern.Monthly); chai_1.expect(entity.useEndDate).to.equal(true); chai_1.expect(entity.monthlyUseOrdinalDay).to.equal(false); chai_1.expect(entity.monthlyDay).to.equal(1); chai_1.expect(entity.weeklyDays).to.equal(model_1.WeekDayType.None); chai_1.expect(entity.yearlyOrdinalNumber).to.equal(model_1.OrdinalNumber.Second); })); }); describe("postTaskRecurringInfo 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 = "sample.mpp"; const localPath = BaseTest.localBaseTestDataFolder + fileName; const remotePath = BaseTest.remoteBaseTestDataFolder; const remoteFullPath = remotePath + "/" + fileName; yield tasksApi.uploadFileToStorage(remoteFullPath, localPath); const recurringInfo = new model_1.RecurringInfo(); recurringInfo.recurrencePattern = model_1.RecurrencePattern.Weekly; recurringInfo.occurrences = 4; recurringInfo.weeklyRepetitions = 3; recurringInfo.weeklyDays = model_1.WeekDayType.Thursday; recurringInfo.startDate = new Date(Date.UTC(2018, 0, 1, 8, 0, 0)); recurringInfo.endDate = new Date(Date.UTC(2018, 11, 31)); recurringInfo.useEndDate = true; const postRequest = new model_1.PostTaskRecurringInfoRequest(); postRequest.name = fileName; postRequest.folder = remotePath; postRequest.recurringInfo = recurringInfo; postRequest.parentTaskUid = 0; postRequest.taskName = "New recurring task"; postRequest.calendarName = "Standard"; const postResult = yield tasksApi.postTaskRecurringInfo(postRequest); chai_1.expect(postResult.body.code).to.equal(201); chai_1.expect(postResult.body.taskItem).is.not.undefined.and.not.null; let getRequest = new model_1.GetTaskRequest(); getRequest.name = fileName; getRequest.folder = remotePath; getRequest.taskUid = postResult.body.taskItem.uid; let getResult = yield tasksApi.getTask(getRequest); chai_1.expect(getResult.response.statusCode).to.equal(200); chai_1.expect(getResult.body.task.subtasksUids.length).to.equal(18); getRequest = new model_1.GetTaskRequest(); getRequest.name = fileName; getRequest.folder = remotePath; getRequest.taskUid = Math.max(...getResult.body.task.subtasksUids); getResult = yield tasksApi.getTask(getRequest); chai_1.expect(getResult.body.task.start).to.eql(new Date(2018, 11, 27, 8, 0, 0)); })); }); //# sourceMappingURL=recurringInfoTests.js.map