Browse Source

Implemented test framework.

tags/v1.0.0
Kalimuthu Selvaraj 5 years ago
parent
commit
eb3591a78d
4 changed files with 45 additions and 3 deletions
  1. 7
    1
      package.json
  2. 2
    2
      sample.js
  3. 0
    0
      sample.txt
  4. 36
    0
      test/test.js

+ 7
- 1
package.json View File

@@ -18,6 +18,12 @@
"author": "Kalimuthu Selvaraj",
"license": "ISC",
"dependencies": {
"async": "^3.2.0"
"async": "^3.2.0",
"office-to-pdf": "^4.0.0",
"pptx2pdf": "^1.0.10"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^7.2.0"
}
}

+ 2
- 2
sample.js View File

@@ -1,9 +1,9 @@
const document = require("../convert");
const document = require("./convert");

const options = {
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe",
sourceFile: "C:\\convert-pdf-img\\metro_powerpoint.pptx",
outputDir: "C:\\convert-pdf-img\\files\\",
outputDir: "abc",
img: true,
imgExt: "jpg",
reSize: 800,

+ 0
- 0
sample.txt View File


+ 36
- 0
test/test.js View File

@@ -0,0 +1,36 @@
"use strict";
var expect = require("chai").expect;
var doc = require("../convert");

describe("Convert files to pdf or/and image", function () {
let options = {
libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe",
sourceFile: "C:\\convert-pdf-img\\metro_powerpoint.pptx",
outputDir: "C:\\convert-pdf-img\\files\\",
img: true,
imgExt: "jpg",
reSize: 800,
density: 120,
};
it("should return source file not exist", function () {
options.sourceFile = "C:\\convert-pdf-img\\metro_powerpoint.pptex";
var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Source file does not exist.");
});
});

it("should return invalid extesion", function () {
options.sourceFile = "C:\\convert-pdf-img\\sample.txt";
var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Invalid extension.");
});
});

it("should return error on image conversion process", function () {
options.sourceFile = "C:\\convert-pdf-img\\metro_powerpoint.pptx";
options.outputDir = "abc";
var result = doc.convert(options, function (err) {
expect(err.message).to.equal("Error on image conversion process.");
});
});
});

Loading…
Cancel
Save