Skip to content

Commit 6226faa

Browse files
Tests codegen
1 parent c328b7b commit 6226faa

File tree

89 files changed

+8141
-8052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+8141
-8052
lines changed
Binary file not shown.

src/api.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ export class WordsApi {
280280
json: true,
281281
};
282282

283-
requestOptions.formData = formParams;
283+
if (Object.keys(formParams).length > 0) {
284+
requestOptions.formData = formParams;
285+
}
284286
const response = await invokeApiMethod(requestOptions, this.configuration);
285287
const body = ObjectSerializer.deserialize(response.body, "DocumentResponse");
286288
const result: model.WordsIncomingMessage< model.DocumentResponse > = {body, response};
@@ -348,7 +350,9 @@ export class WordsApi {
348350
encoding: null,
349351
};
350352

351-
requestOptions.formData = formParams;
353+
if (Object.keys(formParams).length > 0) {
354+
requestOptions.formData = formParams;
355+
}
352356
const response = await invokeApiMethod(requestOptions, this.configuration);
353357
const body = ObjectSerializer.deserialize(response.body, "Buffer");
354358
const result: model.WordsIncomingMessage< Buffer > = {body, response};
@@ -538,7 +542,9 @@ export class WordsApi {
538542
encoding: null,
539543
};
540544

541-
requestOptions.formData = formParams;
545+
if (Object.keys(formParams).length > 0) {
546+
requestOptions.formData = formParams;
547+
}
542548
const response = await invokeApiMethod(requestOptions, this.configuration);
543549
const body = ObjectSerializer.deserialize(response.body, "Buffer");
544550
const result: model.WordsIncomingMessage< Buffer > = {body, response};
@@ -2854,7 +2860,9 @@ export class WordsApi {
28542860
json: true,
28552861
};
28562862

2857-
requestOptions.formData = formParams;
2863+
if (Object.keys(formParams).length > 0) {
2864+
requestOptions.formData = formParams;
2865+
}
28582866
const response = await invokeApiMethod(requestOptions, this.configuration);
28592867
const body = ObjectSerializer.deserialize(response.body, "DocumentResponse");
28602868
const result: model.WordsIncomingMessage< model.DocumentResponse > = {body, response};
@@ -2911,7 +2919,9 @@ export class WordsApi {
29112919
encoding: null,
29122920
};
29132921

2914-
requestOptions.formData = formParams;
2922+
if (Object.keys(formParams).length > 0) {
2923+
requestOptions.formData = formParams;
2924+
}
29152925
const response = await invokeApiMethod(requestOptions, this.configuration);
29162926
const body = ObjectSerializer.deserialize(response.body, "Buffer");
29172927
const result: model.WordsIncomingMessage< Buffer > = {body, response};
@@ -3772,7 +3782,9 @@ export class WordsApi {
37723782
json: true,
37733783
};
37743784

3775-
requestOptions.formData = formParams;
3785+
if (Object.keys(formParams).length > 0) {
3786+
requestOptions.formData = formParams;
3787+
}
37763788
const response = await invokeApiMethod(requestOptions, this.configuration);
37773789
const body = ObjectSerializer.deserialize(response.body, "FieldNamesResponse");
37783790
const result: model.WordsIncomingMessage< model.FieldNamesResponse > = {body, response};
@@ -6892,7 +6904,9 @@ export class WordsApi {
68926904
json: true,
68936905
};
68946906

6895-
requestOptions.formData = formParams;
6907+
if (Object.keys(formParams).length > 0) {
6908+
requestOptions.formData = formParams;
6909+
}
68966910
const response = await invokeApiMethod(requestOptions, this.configuration);
68976911
const body = ObjectSerializer.deserialize(response.body, "DrawingObjectResponse");
68986912
const result: model.WordsIncomingMessage< model.DrawingObjectResponse > = {body, response};
@@ -6964,7 +6978,9 @@ export class WordsApi {
69646978
json: true,
69656979
};
69666980

6967-
requestOptions.formData = formParams;
6981+
if (Object.keys(formParams).length > 0) {
6982+
requestOptions.formData = formParams;
6983+
}
69686984
const response = await invokeApiMethod(requestOptions, this.configuration);
69696985
const body = ObjectSerializer.deserialize(response.body, "DrawingObjectResponse");
69706986
const result: model.WordsIncomingMessage< model.DrawingObjectResponse > = {body, response};
@@ -8145,7 +8161,9 @@ export class WordsApi {
81458161
json: true,
81468162
};
81478163

8148-
requestOptions.formData = formParams;
8164+
if (Object.keys(formParams).length > 0) {
8165+
requestOptions.formData = formParams;
8166+
}
81498167
const response = await invokeApiMethod(requestOptions, this.configuration);
81508168
const body = ObjectSerializer.deserialize(response.body, "DocumentResponse");
81518169
const result: model.WordsIncomingMessage< model.DocumentResponse > = {body, response};
@@ -9855,7 +9873,9 @@ export class WordsApi {
98559873
json: true,
98569874
};
98579875

9858-
requestOptions.formData = formParams;
9876+
if (Object.keys(formParams).length > 0) {
9877+
requestOptions.formData = formParams;
9878+
}
98599879
const response = await invokeApiMethod(requestOptions, this.configuration);
98609880
const body = ObjectSerializer.deserialize(response.body, "DrawingObjectResponse");
98619881
const result: model.WordsIncomingMessage< model.DrawingObjectResponse > = {body, response};
@@ -9938,7 +9958,9 @@ export class WordsApi {
99389958
json: true,
99399959
};
99409960

9941-
requestOptions.formData = formParams;
9961+
if (Object.keys(formParams).length > 0) {
9962+
requestOptions.formData = formParams;
9963+
}
99429964
const response = await invokeApiMethod(requestOptions, this.configuration);
99439965
const body = ObjectSerializer.deserialize(response.body, "DrawingObjectResponse");
99449966
const result: model.WordsIncomingMessage< model.DrawingObjectResponse > = {body, response};
@@ -11292,7 +11314,9 @@ export class WordsApi {
1129211314
json: true,
1129311315
};
1129411316

11295-
requestOptions.formData = formParams;
11317+
if (Object.keys(formParams).length > 0) {
11318+
requestOptions.formData = formParams;
11319+
}
1129611320
const response = await invokeApiMethod(requestOptions, this.configuration);
1129711321
const body = ObjectSerializer.deserialize(response.body, "FilesUploadResult");
1129811322
const result: model.WordsIncomingMessage< model.FilesUploadResult > = {body, response};

test/baseTest.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
/*
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-
*/
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="baseTest.ts">
4+
* Copyright (c) 2020 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
2427

2528
import { createReadStream } from "fs";
2629
import { WordsApi } from "../src/api";
@@ -65,8 +68,8 @@ export class TestWordsApi extends WordsApi {
6568
}
6669

6770
export const remoteBaseFolder = "Temp/SdkTests/node/";
68-
export const remoteBaseTestDataFolder = "Temp/SdkTests/node/TestData/";
69-
export const remoteBaseTestOutFolder = "Temp/SdkTests/node/TestOut/";
71+
export const remoteBaseTestDataFolder = "Temp/SdkTests/node/TestData";
72+
export const remoteBaseTestOutFolder = "Temp/SdkTests/node/TestOut";
7073
export const localBaseTestDataFolder = "./TestData/";
7174
export const localCommonTestDataFolder = "./TestData/Common/";
7275

test/bookmark/bookmarkTests.ts

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="bookmarkTests.ts">
4+
* Copyright (c) 2020 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
import { expect } from "chai";
29+
import "mocha";
30+
31+
import * as fs from "fs";
32+
import * as model from "../../src/model/model";
33+
import * as BaseTest from "../baseTest";
34+
35+
// Example of how to get all bookmarks from document.
36+
describe("bookmark", () => {
37+
expect(fs);
38+
const remoteDataFolder = BaseTest.remoteBaseTestDataFolder + "/DocumentElements/Bookmarks";
39+
const localFile = "Common/test_multi_pages.docx";
40+
41+
// Test for getting bookmarks from document.
42+
describe("getBookmarks test", () => {
43+
it("should return response with code 200", () => {
44+
const wordsApi = BaseTest.initializeWordsApi();
45+
const remoteFileName = "TestGetDocumentBookmarks.docx";
46+
47+
return wordsApi.uploadFileToStorage(
48+
remoteDataFolder + "/" + remoteFileName,
49+
BaseTest.localBaseTestDataFolder + localFile
50+
).then((result0) => {
51+
expect(result0.response.statusMessage).to.equal("OK");
52+
const request = new model.GetBookmarksRequest({
53+
name: remoteFileName,
54+
folder: remoteDataFolder
55+
});
56+
57+
// Act
58+
return wordsApi.getBookmarks(request)
59+
.then((resultApi) => {
60+
// Assert
61+
expect(resultApi.response.statusCode).to.equal(200);
62+
});
63+
64+
});
65+
66+
});
67+
});
68+
69+
// Test for getting bookmark by specified name.
70+
describe("getBookmarkByName test", () => {
71+
it("should return response with code 200", () => {
72+
const wordsApi = BaseTest.initializeWordsApi();
73+
const remoteFileName = "TestGetDocumentBookmarkByName.docx";
74+
75+
return wordsApi.uploadFileToStorage(
76+
remoteDataFolder + "/" + remoteFileName,
77+
BaseTest.localBaseTestDataFolder + localFile
78+
).then((result0) => {
79+
expect(result0.response.statusMessage).to.equal("OK");
80+
const request = new model.GetBookmarkByNameRequest({
81+
name: remoteFileName,
82+
bookmarkName: "aspose",
83+
folder: remoteDataFolder
84+
});
85+
86+
// Act
87+
return wordsApi.getBookmarkByName(request)
88+
.then((resultApi) => {
89+
// Assert
90+
expect(resultApi.response.statusCode).to.equal(200);
91+
});
92+
93+
});
94+
95+
});
96+
});
97+
98+
// Test for updating existed bookmark.
99+
describe("updateBookmark test", () => {
100+
it("should return response with code 200", () => {
101+
const wordsApi = BaseTest.initializeWordsApi();
102+
const remoteFileName = "TestUpdateDocumentBookmark.docx";
103+
const bookmarkName = "aspose";
104+
105+
return wordsApi.uploadFileToStorage(
106+
remoteDataFolder + "/" + remoteFileName,
107+
BaseTest.localBaseTestDataFolder + localFile
108+
).then((result0) => {
109+
expect(result0.response.statusMessage).to.equal("OK");
110+
const request = new model.UpdateBookmarkRequest({
111+
name: remoteFileName,
112+
bookmarkData: new model.BookmarkData({
113+
name: bookmarkName,
114+
text: "This will be the text for Aspose"
115+
}),
116+
bookmarkName: bookmarkName,
117+
folder: remoteDataFolder,
118+
destFileName: BaseTest.remoteBaseTestOutFolder + "/" + remoteFileName
119+
});
120+
121+
// Act
122+
return wordsApi.updateBookmark(request)
123+
.then((resultApi) => {
124+
// Assert
125+
expect(resultApi.response.statusCode).to.equal(200);
126+
});
127+
128+
});
129+
130+
});
131+
});
132+
});

0 commit comments

Comments
 (0)