Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
fix print
Browse files Browse the repository at this point in the history
  • Loading branch information
artiebits committed May 21, 2021
1 parent 4135fd4 commit 6925374
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/unix/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const print = (pdf, options = {}) => {
.forEach((arg) => args.push(arg));
}

return execAsync("lp", args);
return execAsync(`lp ${args.join(" ")}`);
};

module.exports = print;
16 changes: 6 additions & 10 deletions src/unix/print.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test("throws if PDF doesn't exist", () => {
test("sends the PDF file to the default printer", () => {
const filename = "assets/pdf-sample.pdf";
return print(filename).then(() => {
expect(execAsync).toHaveBeenCalledWith("lp", [filename]);
expect(execAsync).toHaveBeenCalledWith(`lp ${filename}`);
});
});

Expand All @@ -50,7 +50,7 @@ test("sends PDF file to the specific printer", () => {
printer,
};
return print(filename, options).then(() => {
expect(execAsync).toHaveBeenCalledWith("lp", [filename, "-d", printer]);
expect(execAsync).toHaveBeenCalledWith(`lp ${filename} -d ${printer}`);
});
});

Expand All @@ -59,7 +59,7 @@ test("sends PDF file to the specific printer with a space in its name", () => {
const printer = "Brother HL-L2340WD";
const options = { printer };
return print(filename, options).then(() => {
expect(execAsync).toHaveBeenCalledWith("lp", [filename, "-d", printer]);
expect(execAsync).toHaveBeenCalledWith(`lp ${filename} -d ${printer}`);
});
});

Expand All @@ -68,13 +68,9 @@ test("allows users to pass OS specific options", () => {
const printer = "Zebra";
const options = { printer, unix: ["-o sides=one-sided"] };
return print(filename, options).then(() => {
expect(execAsync).toHaveBeenCalledWith("lp", [
filename,
"-d",
printer,
"-o",
"sides=one-sided",
]);
expect(execAsync).toHaveBeenCalledWith(
`lp ${filename} -d ${printer} -o sides=one-sided`
);
});
});

Expand Down

0 comments on commit 6925374

Please sign in to comment.