Skip to content

Commit 9c038dc

Browse files
[TASKSCLOUD-275] - Added tests for outline codes endpoints.
1 parent a5969c3 commit 9c038dc

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

test/outlineCodesTests.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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 { GetOutlineCodesRequest, GetOutlineCodeByIndexRequest, DeleteOutlineCodeByIndexRequest } from "../src/model/model";
29+
import * as BaseTest from "./baseTest";
30+
31+
describe("getOutlineCodes function", () => {
32+
it("should return response with code 200 and correct data", async () => {
33+
34+
const tasksApi = BaseTest.initializeTasksApi();
35+
const fileName = "NewProductDev.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 GetOutlineCodesRequest();
43+
request.name = fileName;
44+
request.folder = remotePath;
45+
46+
const result = await tasksApi.getOutlineCodes(request);
47+
48+
expect(result.response.statusCode).to.equal(200);
49+
expect(result.body.outlineCodes).not.undefined.and.not.null;
50+
expect(result.body.outlineCodes.list.length).to.equal(2);
51+
});
52+
});
53+
54+
describe("getOutlineCodeByIndex function", () => {
55+
it("should return response with code 200 and correct data", async () => {
56+
57+
const tasksApi = BaseTest.initializeTasksApi();
58+
const fileName = "NewProductDev.mpp";
59+
const localPath = BaseTest.localBaseTestDataFolder + fileName;
60+
const remotePath = BaseTest.remoteBaseTestDataFolder;
61+
const remoteFullPath = remotePath + "/" + fileName;
62+
63+
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
64+
65+
const request = new GetOutlineCodeByIndexRequest();
66+
request.name = fileName;
67+
request.folder = remotePath;
68+
request.index = 1;
69+
70+
const result = await tasksApi.getOutlineCodeByIndex(request);
71+
72+
expect(result.response.statusCode).to.equal(200);
73+
expect(result.body.outlineCode).not.undefined.and.not.null;
74+
expect(result.body.outlineCode.guid).to.equal("F45D601B-70C5-E311-A5BA-D43D7E937F92");
75+
});
76+
});
77+
78+
describe("deleteOutlineCodeByIndex function", () => {
79+
it("should return response with code 200 and correct data", async () => {
80+
81+
const tasksApi = BaseTest.initializeTasksApi();
82+
const fileName = "NewProductDev.mpp";
83+
const localPath = BaseTest.localBaseTestDataFolder + fileName;
84+
const remotePath = BaseTest.remoteBaseTestDataFolder;
85+
const remoteFullPath = remotePath + "/" + fileName;
86+
87+
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
88+
89+
const request1 = new DeleteOutlineCodeByIndexRequest();
90+
request1.name = fileName;
91+
request1.folder = remotePath;
92+
request1.index = 1;
93+
94+
const result1 = await tasksApi.deleteOutlineCodeByIndex(request1);
95+
96+
expect(result1.response.statusCode).to.equal(200);
97+
98+
const request2 = new GetOutlineCodesRequest();
99+
request2.name = fileName;
100+
request2.folder = remotePath;
101+
102+
const result2 = await tasksApi.getOutlineCodes(request2);
103+
104+
expect(result2.response.statusCode).to.equal(200);
105+
expect(result2.body.outlineCodes).not.undefined.and.not.null;
106+
expect(result2.body.outlineCodes.list.length).to.equal(1);
107+
expect(result2.body.outlineCodes.list[0].index).to.equal(1);
108+
});
109+
});

0 commit comments

Comments
 (0)