Skip to content

Commit 07a3569

Browse files
committed
fix instable encryption tests
1 parent 7403adb commit 07a3569

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

test/specs/encryption.spec.js

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,37 @@
99
describe("Core: Standard Encryption", () => {
1010
beforeAll(loadGlobals);
1111
it("should allow text insertion", () => {
12-
const doc = jsPDF({
12+
const doc = jsPDF({
1313
floatPrecision: 2,
1414
encryption: {
1515
userPassword: "password"
1616
}
1717
});
1818
doc.__private__.setFileId("0000000000000000000000000BADFACE");
19+
doc.__private__.setCreationDate("D:19871210000000+00'00'");
1920
doc.text(10, 10, "This is a test!");
2021
comparePdf(doc.output(), "encrypted_standard.pdf", "encryption");
21-
doc.internal.encryption = null;
22-
doc.internal.encryptionOptions = null;
2322
});
2423
it("should be printable", () => {
25-
const doc = jsPDF({
24+
const doc = jsPDF({
2625
floatPrecision: 2,
2726
encryption: {
2827
userPassword: "password",
2928
userPermissions: ["print"]
3029
}
3130
});
3231
doc.__private__.setFileId("0000000000000000000000000BADFACE");
32+
doc.__private__.setCreationDate("D:19871210000000+00'00'");
3333
doc.text(10, 10, "This is a test!");
3434
comparePdf(doc.output(), "encrypted_printable.pdf", "encryption");
35-
doc.internal.encryption = null;
36-
doc.internal.encryptionOptions = null;
3735
});
3836
it("should display forms properly", () => {
3937
var doc = new jsPDF({
4038
floatPrecision: 2,
4139
encryption: {}
4240
});
4341
doc.__private__.setFileId("0000000000000000000000000BADFACE");
42+
doc.__private__.setCreationDate("D:19871210000000+00'00'");
4443
var {
4544
ComboBox,
4645
ListBox,
@@ -49,7 +48,7 @@ describe("Core: Standard Encryption", () => {
4948
TextField,
5049
PasswordField,
5150
RadioButton,
52-
Appearance,
51+
Appearance
5352
} = jsPDF.AcroForm;
5453

5554
doc.setFontSize(12);
@@ -112,14 +111,9 @@ describe("Core: Standard Encryption", () => {
112111
var radioButton3 = radioGroup.createOption("Test3");
113112
radioButton3.Rect = [50, 190, 20, 10];
114113
radioGroup.setAppearance(Appearance.RadioButton.Cross);
115-
116-
comparePdf(
117-
doc.output(),
118-
"encrypted_withAcroForm.pdf",
119-
"encryption"
120-
);
121114

122-
})
115+
comparePdf(doc.output(), "encrypted_withAcroForm.pdf", "encryption");
116+
});
123117
it("colortype_3_indexed_single_colour_alpha_4_bit_png", () => {
124118
var colortype_3_indexed_single_colour_alpha_4_bit_png =
125119
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAG1BMVEX/////AAD/pQD//wAA/wAAgAAAgIAAAP+BAIC08EFzAAAAAXRSTlMAQObYZgAAAJtJREFUCB0BkABv/wAREQAAAAAAAAAiIhEQAAAAAAAzMyIhEAAAAABERDMyIQAAAABVVUQzIhAAAABmZlVEMyEAAAB3d2ZVQzIQAACIh3dlVDIhAAAACId2VUMhAAAAAAiHZUMyEAAAAACHdlQyEAAAAAAIdlQyEAAAAAAId2VDIQAAAAAAh2VDIQAAAAAAh2VDIQAAAAAAh2VDIWfgFTHZzlYNAAAAAElFTkSuQmCC";
@@ -134,6 +128,7 @@ describe("Core: Standard Encryption", () => {
134128
}
135129
});
136130
doc.__private__.setFileId("0000000000000000000000000BADFACE");
131+
doc.__private__.setCreationDate("D:19871210000000+00'00'");
137132
doc.addImage(
138133
colortype_3_indexed_single_colour_alpha_4_bit_png,
139134
"PNG",
@@ -144,12 +139,6 @@ describe("Core: Standard Encryption", () => {
144139
undefined,
145140
undefined
146141
);
147-
comparePdf(
148-
doc.output(),
149-
"encrypted_withImage.pdf",
150-
"encryption"
151-
);
152-
doc.internal.encryption = null;
153-
doc.internal.encryptionOptions = null;
142+
comparePdf(doc.output(), "encrypted_withImage.pdf", "encryption");
154143
});
155144
});

0 commit comments

Comments
 (0)