Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the "checks that the viewer re-exports the expected API functionality" unit-test in Node.js #19358

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,20 +1950,25 @@ function createBaseline(done) {

gulp.task(
"unittestcli",
gulp.series(setTestEnv, "lib-legacy", function runUnitTestCli(done) {
const options = [
"node_modules/jasmine/bin/jasmine",
"JASMINE_CONFIG_PATH=test/unit/clitests.json",
];
const jasmineProcess = startNode(options, { stdio: "inherit" });
jasmineProcess.on("close", function (code) {
if (code !== 0) {
done(new Error("Unit tests failed."));
return;
}
done();
});
})
gulp.series(
setTestEnv,
"generic-legacy",
"lib-legacy",
function runUnitTestCli(done) {
const options = [
"node_modules/jasmine/bin/jasmine",
"JASMINE_CONFIG_PATH=test/unit/clitests.json",
];
const jasmineProcess = startNode(options, { stdio: "inherit" });
jasmineProcess.on("close", function (code) {
if (code !== 0) {
done(new Error("Unit tests failed."));
return;
}
done();
});
}
)
);

gulp.task("lint", function (done) {
Expand Down
20 changes: 13 additions & 7 deletions test/unit/pdf_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
FeatureTest,
ImageKind,
InvalidPDFException,
isNodeJS,
normalizeUnicode,
OPS,
PasswordResponses,
Expand Down Expand Up @@ -129,13 +128,20 @@ describe("pdfjs_api", function () {

describe("web_pdfjsLib", function () {
it("checks that the viewer re-exports the expected API functionality", async function () {
if (isNodeJS) {
pending("loadScript is not supported in Node.js.");
}
const apiPath = "../../build/generic/build/pdf.mjs";
await import(apiPath);
// Load the API globally, as the viewer does.
// eslint-disable-next-line no-unsanitized/method
await import(
typeof PDFJSDev !== "undefined" && PDFJSDev.test("LIB")
? "../../../generic-legacy/build/pdf.mjs"
: "../../build/generic/build/pdf.mjs"
);

const webPdfjsLib = await import("../../web/pdfjs.js");
// eslint-disable-next-line no-unsanitized/method
const webPdfjsLib = await import(
typeof PDFJSDev !== "undefined" && PDFJSDev.test("LIB")
? "../../../../web/pdfjs.js"
: "../../web/pdfjs.js"
);

expect(Object.keys(webPdfjsLib).sort()).toEqual(
Object.keys(expectedAPI).sort()
Expand Down
Loading