From 52aa0e6cc3f1dcbeaa389fea42ad987c44b7ea74 Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Sun, 16 Jul 2023 20:08:41 +0300 Subject: [PATCH 1/2] Handle multiple file params --- src/task.js | 9 +++++---- test/index.js | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/task.js b/src/task.js index 82d55db..0590c97 100644 --- a/src/task.js +++ b/src/task.js @@ -31,11 +31,12 @@ const Task = class { async normalizeParams(params) { const result = Object.assign({}, params, this.defaultParams); + const fileParams = Object.keys(params).filter(key => key.endsWith('File') && key !== 'StoreFile'); - if (params.File) { - const file = await params.File; - result.File = await buildFileParam(this.api, file); - } + await Promise.all(fileParams.map(async (key) => { + const file = await params[key]; + result[key] = await buildFileParam(this.api, file); + })); if (params.Files) { const files = await normalizeFilesParam(params.Files); diff --git a/test/index.js b/test/index.js index d635950..6698fa1 100644 --- a/test/index.js +++ b/test/index.js @@ -119,6 +119,17 @@ describe('ConvertAPI', () => { expect(result.file.url).to.be.a('string'); }); + it('should compare files', async () => { + const params = { + File: './examples/files/test.docx', + CompareFile: './examples/files/test.docx', + }; + + const result = await api.convert('compare', params); + + expect(result.file.url).to.be.a('string'); + }); + it('should handle api errors', () => { const params = { Url: 'https://www.w3.org/TR/PNG/iso_8859-1.txt' }; From 8c6665143bb65cef9be9af50448a0de38ecee8e3 Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Sun, 16 Jul 2023 20:25:49 +0300 Subject: [PATCH 2/2] Update node test versions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f92a16..70acc50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,10 +6,10 @@ jobs: strategy: matrix: node-version: + - 20 - 18 - 14 - 10 - - 6 name: Node ${{ matrix.node-version }} sample steps: - uses: actions/checkout@v3