Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

test.js 1.9KB

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