Skip to content

Commit a5c1ea2

Browse files
committed
fix tests
1 parent 4da55c0 commit a5c1ea2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

test/specs/context2d.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ describe("Context2D: standard tests", () => {
177177
doc.addFont("fa-solid-900.ttf", "Font Awesome 6 Free Solid", "normal");
178178

179179
const ctx = doc.context2d;
180-
ctx.font = "normal 16pt \"Font Awesome 6 Free Solid\"";
180+
ctx.font = 'normal 16pt "Font Awesome 6 Free Solid"';
181181

182182
expect(doc.getFont().fontName).toBe("Font Awesome 6 Free Solid");
183183
});
@@ -762,12 +762,17 @@ describe("Context2D: standard tests", () => {
762762
});
763763

764764
it("font face map cache invalidation", () => {
765+
const ptSans = loadBinaryResource("reference/PTSans.ttf");
766+
765767
var doc = new jsPDF({
766768
orientation: "p",
767769
unit: "pt",
768770
format: "a4",
769771
floatPrecision: 2
770772
});
773+
doc.addFileToVFS("CustomFont", ptSans);
774+
doc.addFont("CustomFont", "CustomFont", "normal");
775+
771776
var ctx = doc.context2d;
772777

773778
// Set up font faces for context2d
@@ -786,7 +791,8 @@ describe("Context2D: standard tests", () => {
786791

787792
// Add a new font to the document (simulating dynamic font loading)
788793
// This should trigger font face map cache invalidation
789-
doc.addFont("dummy-font-data", "NewCustomFont", "normal");
794+
doc.addFileToVFS("NewCustomFont", ptSans);
795+
doc.addFont("NewCustomFont", "NewCustomFont", "normal");
790796

791797
// Change font again - this should rebuild the font face map
792798
// and not use stale cached data

test/specs/encryption.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ describe("Core: Standard Encryption", () => {
2828
userPermissions: ["print"]
2929
}
3030
});
31+
const oldVersion = jsPDF.version;
32+
jsPDF.version = "3.0.3";
3133
doc.__private__.setFileId("0000000000000000000000000BADFACE");
3234
doc.__private__.setCreationDate("D:19871210000000+00'00'");
3335
doc.text(10, 10, "This is a test!");
3436
comparePdf(doc.output(), "encrypted_printable.pdf", "encryption");
37+
jsPDF.version = oldVersion;
3538
});
3639
it("should display forms properly", () => {
3740
var doc = new jsPDF({

0 commit comments

Comments
 (0)