You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. var chai = require("chai").use(require("chai-as-promised"));
  3. var document = require("../convert");
  4. var expect = chai.expect;
  5. describe("Convert files to pdf or/and image", function () {
  6. const options = {
  7. libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\sooffice.exe",
  8. sourceFile: "C:\\node\\document-convert\\source\\Metro_Style.pptx",
  9. outputDir: "C:\\node\\document-convert\\files\\",
  10. img: true,
  11. };
  12. it("Should return libre office bin does not exist", function (done) {
  13. document.convert(options).catch((e) => {
  14. expect(e.message).to.equal(`${options.libreofficeBin} does not exist`);
  15. done();
  16. });
  17. });
  18. it("should return invalid extesion", function () {
  19. options.libreofficeBin = "/usr/bin/libreoffice";
  20. options.sourceFile = "C:\\node\\document-convert\\source\\sample.txt";
  21. document.convert(options).catch((e) => {
  22. expect(e.message).to.equal("Invalid extension.");
  23. });
  24. });
  25. it("should convert pdf to image", function () {
  26. options.sourceFile = "C:\\node\\document-convert\\source\\Metro_Style.pdf";
  27. options.outputDir = "C:\\node\\document-convert\\files\\";
  28. options.reSize = 800;
  29. document.convert(options).then((res) => {
  30. expect(res).to.equal("Success");
  31. });
  32. });
  33. it("should convert pdf only", function (done) {
  34. options.sourceFile = "C:\\node\\document-convert\\source\\Metro_Style.pptx";
  35. options.img = false;
  36. document.convert(options).then((res) => {
  37. expect(res).to.equal("Success");
  38. done();
  39. });
  40. });
  41. it("should convert without resize, density and imgExt", function () {
  42. options.img = true;
  43. document.convert(options).then((res) => {
  44. expect(res).to.equal("Success");
  45. });
  46. });
  47. });