|
| 1 | +/* |
| 2 | +* MIT License |
| 3 | +
|
| 4 | +* Copyright (c) 2021 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 * as model from "../src/model/model"; |
| 29 | +import * as BaseTest from "./baseTest"; |
| 30 | +var fs = require('fs'); |
| 31 | +var path = require('path'); |
| 32 | +var assert = require('assert'); |
| 33 | +var filename = "Book1.xlsx"; |
| 34 | +const localPath = "TestData/"; |
| 35 | + |
| 36 | +describe('Cells sdk for NodeJS test ok.', function() { |
| 37 | + it('should call postBatchConvert successfully', function() { |
| 38 | + const cellsApi = BaseTest.initializeCellsApi(); |
| 39 | + filename = "Book1.xlsx"; |
| 40 | + var data =fs.createReadStream(localPath + filename); |
| 41 | + var req = new model.UploadFileRequest(); |
| 42 | + req.path = "Temp/" + filename; |
| 43 | + req.file = data; |
| 44 | + |
| 45 | + return cellsApi.uploadFile(req) |
| 46 | + .then((result) => { |
| 47 | + expect(result.body.uploaded.length).greaterThan(0); |
| 48 | + filename = "myDocument.xlsx"; |
| 49 | + var data =fs.createReadStream(localPath + filename); |
| 50 | + var req = new model.UploadFileRequest(); |
| 51 | + req.path = "Temp/" + filename; |
| 52 | + req.file = data; |
| 53 | + |
| 54 | + return cellsApi.uploadFile(req) |
| 55 | + .then((result) => { |
| 56 | + expect(result.body.toString().length).to.greaterThan(0); |
| 57 | + filename = "datasource.xlsx"; |
| 58 | + var data =fs.createReadStream(localPath + filename); |
| 59 | + var req = new model.UploadFileRequest(); |
| 60 | + req.path = "Temp/" + filename; |
| 61 | + req.file = data; |
| 62 | + |
| 63 | + return cellsApi.uploadFile(req) |
| 64 | + .then((result) => { |
| 65 | + expect(result.body.toString().length).to.greaterThan(0); |
| 66 | + filename = "assemblytest.xlsx"; |
| 67 | + var data =fs.createReadStream(localPath + filename); |
| 68 | + var req = new model.UploadFileRequest(); |
| 69 | + req.path = "Temp/" + filename; |
| 70 | + req.file = data; |
| 71 | + |
| 72 | + return cellsApi.uploadFile(req) |
| 73 | + .then((result) => { |
| 74 | + expect(result.body.toString().length).to.greaterThan(0); |
| 75 | + var req = new model.PostBatchConvertRequest(); |
| 76 | + req.batchConvertRequest = new model.BatchConvertRequest(); |
| 77 | + req.batchConvertRequest.format = "pdf"; |
| 78 | + req.batchConvertRequest.sourceFolder = "Temp"; |
| 79 | + req.batchConvertRequest.matchCondition = new model.MatchConditionRequest(); |
| 80 | + req.batchConvertRequest.matchCondition.fullMatchConditions = new Array<string>(); |
| 81 | + req.batchConvertRequest.matchCondition.fullMatchConditions.push( "assemblytest.xlsx"); |
| 82 | + return cellsApi.postBatchConvert(req) |
| 83 | + .then((result) => { |
| 84 | + expect(result.body.toString().length).to.greaterThan(0); |
| 85 | + |
| 86 | + }); |
| 87 | + }); |
| 88 | + }); |
| 89 | + }); |
| 90 | + }); |
| 91 | + }); |
| 92 | + |
| 93 | +}); |
0 commit comments