Skip to content

Commit 47a2e3e

Browse files
[TASKSCLOUD-273] - Added tests for page count endpoints.
1 parent 7bf8cb9 commit 47a2e3e

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

test/getPageCountTests.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* MIT License
3+
4+
* Copyright (c) 2019 Aspose Pty Ltd
5+
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
import { expect } from "chai";
26+
import "mocha";
27+
28+
import { GetPageCountRequest, PresentationFormat, Timescale } from "../src/model/model";
29+
import * as BaseTest from "./baseTest";
30+
31+
describe("getPageCount function", () => {
32+
it("should return response with code 200 and correct data", async () => {
33+
34+
const tasksApi = BaseTest.initializeTasksApi();
35+
const fileName = "Home_move_plan.mpp";
36+
const localPath = BaseTest.localBaseTestDataFolder + fileName;
37+
const remotePath = BaseTest.remoteBaseTestDataFolder;
38+
const remoteFullPath = remotePath + "/" + fileName;
39+
40+
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
41+
42+
const request = new GetPageCountRequest();
43+
request.name = fileName;
44+
request.folder = remotePath;
45+
request.presentationFormat = PresentationFormat.TaskUsage;
46+
request.timescale = Timescale.Months;
47+
48+
const result = await tasksApi.getPageCount(request);
49+
50+
expect(result.response.statusCode).to.equal(200);
51+
expect(result.body.pageCount).to.equal(2);
52+
});
53+
it("should return response with code 200 and correct data with specified presentation format and date interval", async () => {
54+
55+
const tasksApi = BaseTest.initializeTasksApi();
56+
const fileName = "Home_move_plan.mpp";
57+
const localPath = BaseTest.localBaseTestDataFolder + fileName;
58+
const remotePath = BaseTest.remoteBaseTestDataFolder;
59+
const remoteFullPath = remotePath + "/" + fileName;
60+
61+
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
62+
63+
const request = new GetPageCountRequest();
64+
request.name = fileName;
65+
request.folder = remotePath;
66+
request.presentationFormat = PresentationFormat.TaskUsage;
67+
request.timescale = Timescale.Months;
68+
request.startDate = new Date(2004, 0, 1);
69+
request.endDate = new Date(2004, 1, 28);
70+
71+
const result = await tasksApi.getPageCount(request);
72+
73+
expect(result.response.statusCode).to.equal(200);
74+
expect(result.body.pageCount).to.equal(2);
75+
});
76+
});

0 commit comments

Comments
 (0)