您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 =
  20. "C:\\Program Files\\LibreOffice\\program\\soffice.exe";
  21. options.sourceFile = "C:\\node\\document-convert\\source\\sample.txt";
  22. document.convert(options).catch((e) => {
  23. expect(e.message).to.equal("Invalid extension.");
  24. });
  25. });
  26. it("should convert pdf to image", function () {
  27. options.sourceFile = "C:\\node\\document-convert\\source\\Metro_Style.pdf";
  28. options.outputDir = "C:\\node\\document-convert\\files\\";
  29. options.reSize = 800;
  30. document.convert(options).then((res) => {
  31. expect(res).to.equal("Success");
  32. });
  33. });
  34. it("should convert pdf only", function (done) {
  35. options.sourceFile = "C:\\node\\document-convert\\source\\Metro_Style.pptx";
  36. options.img = false;
  37. document.convert(options).then((res) => {
  38. expect(res).to.equal("Success");
  39. done();
  40. });
  41. });
  42. it("should convert without resize, density and imgExt", function () {
  43. options.img = true;
  44. document.convert(options).then((res) => {
  45. expect(res).to.equal("Success");
  46. });
  47. });
  48. });