Skip to content

Commit 4a4e9e9

Browse files
author
kirill.novinskiy@aspose.com
committed
added compare tests
1 parent 3603d79 commit 4a4e9e9

File tree

5 files changed

+59
-77
lines changed

5 files changed

+59
-77
lines changed

docs/PdfApi.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,12 +2662,12 @@ Convert MHT file (located on storage) to PDF format and return resulting file in
26622662
Name | Type | Description | Notes
26632663
------------- | ------------- | ------------- | -------------
26642664
**srcPath** | **string** | Full source filename (ex. /folder1/folder2/template.mht) |
2665-
**height** | **number** | Page height |
2666-
**width** | **number** | Page width |
2667-
**marginLeft** | **number** | Page margin left |
2668-
**marginBottom** | **number** | Page margin bottom |
2669-
**marginRight** | **number** | Page margin right |
2670-
**marginTop** | **number** | Page margin top |
2665+
**height** | **number** | Page height | [optional]
2666+
**width** | **number** | Page width | [optional]
2667+
**marginLeft** | **number** | Page margin left | [optional]
2668+
**marginBottom** | **number** | Page margin bottom | [optional]
2669+
**marginRight** | **number** | Page margin right | [optional]
2670+
**marginTop** | **number** | Page margin top | [optional]
26712671
**storage** | **string** | The document storage. | [optional]
26722672

26732673
### Return type
@@ -7555,12 +7555,12 @@ Name | Type | Description | Notes
75557555
------------- | ------------- | ------------- | -------------
75567556
**name** | **string** | The document name. |
75577557
**srcPath** | **string** | Full source filename (ex. /folder1/folder2/template.mht) |
7558-
**height** | **number** | Page height |
7559-
**width** | **number** | Page width |
7560-
**marginLeft** | **number** | Page margin left |
7561-
**marginBottom** | **number** | Page margin bottom |
7562-
**marginRight** | **number** | Page margin right |
7563-
**marginTop** | **number** | Page margin top |
7558+
**height** | **number** | Page height | [optional]
7559+
**width** | **number** | Page width | [optional]
7560+
**marginLeft** | **number** | Page margin left | [optional]
7561+
**marginBottom** | **number** | Page margin bottom | [optional]
7562+
**marginRight** | **number** | Page margin right | [optional]
7563+
**marginTop** | **number** | Page margin top | [optional]
75647564
**dstFolder** | **string** | The destination document folder. | [optional]
75657565
**storage** | **string** | The document storage. | [optional]
75667566

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"main": "src/api/api.js",
124124
"types": "src/api/api.d.ts",
125125
"scripts": {
126-
"clean": "rm -Rf node_modules/ typings/ *.js",
126+
"clean": "find src test -type f -name '*.js' -delete -o -name '*.d.ts' -delete -o -name '*.js.map' -delete",
127127
"build": "tsc",
128128
"test": "mocha -r ts-node/register test/test*.ts --timeout 600000"
129129
},

src/api/api.ts

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6054,7 +6054,7 @@ export class PdfApi {
60546054
* @param marginTop Page margin top
60556055
* @param storage The document storage.
60566056
*/
6057-
public async getMhtInStorageToPdf (srcPath: string, height: number, width: number, marginLeft: number, marginBottom: number, marginRight: number, marginTop: number, storage?: string) : Promise<{ response: http.IncomingMessage; body: Buffer; }> {
6057+
public async getMhtInStorageToPdf (srcPath: string, height?: number, width?: number, marginLeft?: number, marginBottom?: number, marginRight?: number, marginTop?: number, storage?: string) : Promise<{ response: http.IncomingMessage; body: Buffer; }> {
60586058
const localVarPath = this.basePath + '/pdf/create/mht';
60596059
let localVarQueryParameters: any = {};
60606060
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
@@ -6065,36 +6065,6 @@ export class PdfApi {
60656065
throw new Error('Required parameter srcPath was null or undefined when calling getMhtInStorageToPdf.');
60666066
}
60676067

6068-
// verify required parameter 'height' is not null or undefined
6069-
if (height === null || height === undefined) {
6070-
throw new Error('Required parameter height was null or undefined when calling getMhtInStorageToPdf.');
6071-
}
6072-
6073-
// verify required parameter 'width' is not null or undefined
6074-
if (width === null || width === undefined) {
6075-
throw new Error('Required parameter width was null or undefined when calling getMhtInStorageToPdf.');
6076-
}
6077-
6078-
// verify required parameter 'marginLeft' is not null or undefined
6079-
if (marginLeft === null || marginLeft === undefined) {
6080-
throw new Error('Required parameter marginLeft was null or undefined when calling getMhtInStorageToPdf.');
6081-
}
6082-
6083-
// verify required parameter 'marginBottom' is not null or undefined
6084-
if (marginBottom === null || marginBottom === undefined) {
6085-
throw new Error('Required parameter marginBottom was null or undefined when calling getMhtInStorageToPdf.');
6086-
}
6087-
6088-
// verify required parameter 'marginRight' is not null or undefined
6089-
if (marginRight === null || marginRight === undefined) {
6090-
throw new Error('Required parameter marginRight was null or undefined when calling getMhtInStorageToPdf.');
6091-
}
6092-
6093-
// verify required parameter 'marginTop' is not null or undefined
6094-
if (marginTop === null || marginTop === undefined) {
6095-
throw new Error('Required parameter marginTop was null or undefined when calling getMhtInStorageToPdf.');
6096-
}
6097-
60986068
if (srcPath !== undefined && null !== srcPath) {
60996069
localVarQueryParameters['srcPath'] = ObjectSerializer.serialize(srcPath, "string");
61006070
}
@@ -19451,7 +19421,7 @@ export class PdfApi {
1945119421
* @param dstFolder The destination document folder.
1945219422
* @param storage The document storage.
1945319423
*/
19454-
public async putMhtInStorageToPdf (name: string, srcPath: string, height: number, width: number, marginLeft: number, marginBottom: number, marginRight: number, marginTop: number, dstFolder?: string, storage?: string) : Promise<{ response: http.IncomingMessage; body: AsposeResponse; }> {
19424+
public async putMhtInStorageToPdf (name: string, srcPath: string, height?: number, width?: number, marginLeft?: number, marginBottom?: number, marginRight?: number, marginTop?: number, dstFolder?: string, storage?: string) : Promise<{ response: http.IncomingMessage; body: AsposeResponse; }> {
1945519425
const localVarPath = this.basePath + '/pdf/{name}/create/mht'
1945619426
.replace('{' + 'name' + '}', encodeURIComponent(String(name)).replace('%2F', '/'));
1945719427
let localVarQueryParameters: any = {};
@@ -19468,36 +19438,6 @@ export class PdfApi {
1946819438
throw new Error('Required parameter srcPath was null or undefined when calling putMhtInStorageToPdf.');
1946919439
}
1947019440

19471-
// verify required parameter 'height' is not null or undefined
19472-
if (height === null || height === undefined) {
19473-
throw new Error('Required parameter height was null or undefined when calling putMhtInStorageToPdf.');
19474-
}
19475-
19476-
// verify required parameter 'width' is not null or undefined
19477-
if (width === null || width === undefined) {
19478-
throw new Error('Required parameter width was null or undefined when calling putMhtInStorageToPdf.');
19479-
}
19480-
19481-
// verify required parameter 'marginLeft' is not null or undefined
19482-
if (marginLeft === null || marginLeft === undefined) {
19483-
throw new Error('Required parameter marginLeft was null or undefined when calling putMhtInStorageToPdf.');
19484-
}
19485-
19486-
// verify required parameter 'marginBottom' is not null or undefined
19487-
if (marginBottom === null || marginBottom === undefined) {
19488-
throw new Error('Required parameter marginBottom was null or undefined when calling putMhtInStorageToPdf.');
19489-
}
19490-
19491-
// verify required parameter 'marginRight' is not null or undefined
19492-
if (marginRight === null || marginRight === undefined) {
19493-
throw new Error('Required parameter marginRight was null or undefined when calling putMhtInStorageToPdf.');
19494-
}
19495-
19496-
// verify required parameter 'marginTop' is not null or undefined
19497-
if (marginTop === null || marginTop === undefined) {
19498-
throw new Error('Required parameter marginTop was null or undefined when calling putMhtInStorageToPdf.');
19499-
}
19500-
1950119441
if (srcPath !== undefined && null !== srcPath) {
1950219442
localVarQueryParameters['srcPath'] = ObjectSerializer.serialize(srcPath, "string");
1950319443
}

test/testConvertToPdf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe("Convert To PDF Tests", () => {
136136

137137
it("should return response with code 200", async () => {
138138

139-
return BaseTest.getPdfApi().getMhtInStorageToPdf(srcPath)
139+
return BaseTest.getPdfApi().getMhtInStorageToPdf(srcPath, undefined, undefined, undefined, undefined, undefined, undefined)
140140
.then((result) => {
141141
assert.equal(result.response.statusCode, 200);
142142
});
@@ -147,7 +147,7 @@ describe("Convert To PDF Tests", () => {
147147

148148
it("should return response with code 200", async () => {
149149

150-
return BaseTest.getPdfApi().putMhtInStorageToPdf(resFileName, srcPath, BaseTest.remoteTempFolder)
150+
return BaseTest.getPdfApi().putMhtInStorageToPdf(resFileName, srcPath, undefined, undefined, undefined, undefined, undefined, undefined, BaseTest.remoteTempFolder)
151151
.then((result) => {
152152
assert.equal(result.response.statusCode, 200);
153153
});

test/testOrganize.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
*
3+
* Copyright (c) 2025 Aspose.PDF Cloud
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
* The above copyright notice and this permission notice shall be included in all
11+
* copies or substantial portions of the Software.
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
* SOFTWARE.
19+
*
20+
*/
21+
22+
import * as BaseTest from "./baseTestPdfApi";
23+
import "mocha";
24+
var assert = require('assert');
25+
26+
describe("Organize Tests", () => {
27+
28+
describe("Compare two PDF documents", () => {
29+
30+
it("should return response with code 200", async () => {
31+
32+
const name1 = "4pages.pdf";
33+
await BaseTest.uploadFile(name1);
34+
const name2 = "4pagesPdfA.pdf";
35+
await BaseTest.uploadFile(name2);
36+
const output = "output.pdf";
37+
38+
var result = await BaseTest.getPdfApi().postComparePdf(BaseTest.remoteTempFolder + '/' + name1, BaseTest.remoteTempFolder + '/' + name2, output)
39+
assert.equal(result.response.statusCode, 200);
40+
});
41+
});
42+
});

0 commit comments

Comments
 (0)