From 62d211ee8d541cd270664e63debd3ffc387825c0 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 25 Jul 2026 23:52:28 +0200 Subject: [PATCH] Use the `toBeTrue()` matcher consistently in the unit/font/integration tests This replaces all `toEqual(true)` and `toBe(true)` occurrences. --- test/font/font_core_spec.js | 4 +- test/font/font_fpgm_spec.js | 2 +- test/font/font_glyf_spec.js | 6 +- test/font/font_os2_spec.js | 4 +- test/font/font_post_spec.js | 6 +- test/integration/accessibility_spec.mjs | 2 +- test/integration/annotation_spec.mjs | 34 +-- test/integration/copy_paste_spec.mjs | 20 +- test/integration/freetext_editor_spec.mjs | 12 +- test/integration/highlight_editor_spec.mjs | 14 +- test/integration/scripting_spec.mjs | 30 +-- test/integration/stamp_editor_spec.mjs | 12 +- test/integration/text_layer_images_spec.mjs | 2 +- test/integration/viewer_spec.mjs | 10 +- test/unit/annotation_spec.js | 76 +++---- test/unit/annotation_storage_spec.js | 8 +- test/unit/api_spec.js | 230 ++++++++++---------- test/unit/cff_parser_spec.js | 14 +- test/unit/cmap_spec.js | 12 +- test/unit/common_pdfstream_tests.js | 2 +- test/unit/core_utils_spec.js | 18 +- test/unit/crypto_spec.js | 16 +- test/unit/custom_spec.js | 2 +- test/unit/display_utils_spec.js | 8 +- test/unit/document_spec.js | 2 +- test/unit/encodings_spec.js | 2 +- test/unit/evaluator_spec.js | 28 +-- test/unit/event_utils_spec.js | 8 +- test/unit/fetch_stream_spec.js | 8 +- test/unit/message_handler_spec.js | 10 +- test/unit/network_spec.js | 8 +- test/unit/node_stream_spec.js | 4 +- test/unit/obj_bin_transform_spec.js | 20 +- test/unit/parser_spec.js | 2 +- test/unit/pdf_find_utils_spec.js | 24 +- test/unit/pdf_history_spec.js | 12 +- test/unit/pdf_viewer_spec.js | 2 +- test/unit/postscript_spec.js | 24 +- test/unit/primitives_spec.js | 18 +- test/unit/scripting_spec.js | 110 +++++----- test/unit/string_utils_spec.js | 4 +- test/unit/ui_utils_spec.js | 12 +- test/unit/xfa_formcalc_spec.js | 10 +- test/unit/xfa_tohtml_spec.js | 2 +- 44 files changed, 424 insertions(+), 430 deletions(-) diff --git a/test/font/font_core_spec.js b/test/font/font_core_spec.js index 0eae7dab2..660b95b21 100644 --- a/test/font/font_core_spec.js +++ b/test/font/font_core_spec.js @@ -11,8 +11,8 @@ describe("font1", function () { const output = await ttx(font1_1); verifyTtxOutput(output); - expect(//.test(output)).toEqual(true); + expect(//.test(output)).toBeTrue(); }); }); }); diff --git a/test/font/font_fpgm_spec.js b/test/font/font_fpgm_spec.js index 164fd1222..eed45991c 100644 --- a/test/font/font_fpgm_spec.js +++ b/test/font/font_fpgm_spec.js @@ -39,7 +39,7 @@ describe("font_fpgm", function () { /(?:ENDF\[ \]|SVTCA\[0\])\s*\/\*.*\*\/\s*<\/assembly>\s*<\/fpgm>/.test( output ) - ).toEqual(true); + ).toBeTrue(); }); }); }); diff --git a/test/font/font_glyf_spec.js b/test/font/font_glyf_spec.js index 17b996347..3b69f6bb9 100644 --- a/test/font/font_glyf_spec.js +++ b/test/font/font_glyf_spec.js @@ -133,9 +133,9 @@ describe("font_glyf", function () { verifyTtxOutput(output); expect( /\s*(?:\s*)?/.test(output) - ).toEqual(true); - expect(/\s*\s*/.test(output) - ).toEqual(true); + ).toBeTrue(); }); it("has invalid selection attributes presence", async function () { @@ -65,7 +65,7 @@ describe("font_os2", function () { verifyTtxOutput(output); expect( /\s*\s*/.test(output) - ).toEqual(true); + ).toBeTrue(); }); }); }); diff --git a/test/font/font_post_spec.js b/test/font/font_post_spec.js index 15b7edfde..48918a821 100644 --- a/test/font/font_post_spec.js +++ b/test/font/font_post_spec.js @@ -43,7 +43,7 @@ describe("font_post", function () { const output = await ttx(font.data); verifyTtxOutput(output); - expect(/\s*/.test(output)).toEqual(true); + expect(/\s*/.test(output)).toBeTrue(); }); it("has invalid glyph name indexes", async function () { @@ -65,7 +65,7 @@ describe("font_post", function () { const output = await ttx(font.data); verifyTtxOutput(output); - expect(/\s*/.test(output)).toEqual(true); + expect(/\s*/.test(output)).toBeTrue(); }); it("has right amount of glyphs specified", async function () { @@ -87,7 +87,7 @@ describe("font_post", function () { const output = await ttx(font.data); verifyTtxOutput(output); - expect(/\s*/.test(output)).toEqual(true); + expect(/\s*/.test(output)).toBeTrue(); }); }); }); diff --git a/test/integration/accessibility_spec.mjs b/test/integration/accessibility_spec.mjs index 330b1d434..69d962b8e 100644 --- a/test/integration/accessibility_spec.mjs +++ b/test/integration/accessibility_spec.mjs @@ -239,7 +239,7 @@ describe("accessibility", () => { ); expect(isLinkedToStampAnnotation) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); }) ); }); diff --git a/test/integration/annotation_spec.mjs b/test/integration/annotation_spec.mjs index 7b07d840c..29516bdea 100644 --- a/test/integration/annotation_spec.mjs +++ b/test/integration/annotation_spec.mjs @@ -51,7 +51,7 @@ describe("Annotation highlight", () => { highlightSelector, popupSelector ); - expect(areSiblings).withContext(`In ${browserName}`).toEqual(true); + expect(areSiblings).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -63,7 +63,7 @@ describe("Annotation highlight", () => { getAnnotationSelector("21R"), el => el.hidden ); - expect(hidden).withContext(`In ${browserName}`).toEqual(true); + expect(hidden).withContext(`In ${browserName}`).toBeTrue(); await page.hover(getAnnotationSelector("19R")); await page.waitForSelector(getAnnotationSelector("21R"), { visible: true, @@ -159,7 +159,7 @@ describe("Checkbox annotation", () => { await page.waitForFunction( `document.querySelector('${selector} input').checked` ); - expect(true).withContext(`In ${browserName}`).toEqual(true); + expect(true).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -343,7 +343,7 @@ describe("Annotation and storage", () => { getSelector(checkId), el => el.checked ); - expect(checked).toEqual(true); + expect(checked).toBeTrue(); checked = await page.$eval(getSelector(radio1Id), el => el.checked); expect(checked).toBeFalse(); @@ -449,13 +449,13 @@ describe("ResetForm action", () => { `${getSelector("78R")} [value="a"]`, el => el.selected ); - expect(selected).withContext(`In ${browserName}`).toEqual(true); + expect(selected).withContext(`In ${browserName}`).toBeTrue(); selected = await page.$eval( `${getSelector("81R")} [value="d"]`, el => el.selected ); - expect(selected).withContext(`In ${browserName}`).toEqual(true); + expect(selected).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -504,20 +504,20 @@ describe("ResetForm action", () => { getSelector(`${id}R`), el => el.checked ); - expect(checked).withContext(`In ${browserName}`).toEqual(true); + expect(checked).withContext(`In ${browserName}`).toBeTrue(); } let selected = await page.$eval( `${getSelector("78R")} [value="a"]`, el => el.selected ); - expect(selected).withContext(`In ${browserName}`).toEqual(true); + expect(selected).withContext(`In ${browserName}`).toBeTrue(); selected = await page.$eval( `${getSelector("81R")} [value="f"]`, el => el.selected ); - expect(selected).withContext(`In ${browserName}`).toEqual(true); + expect(selected).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -636,7 +636,7 @@ describe("ResetForm action", () => { pages.map(async ([browserName, page]) => { const selector = getAnnotationSelector("21R"); let hidden = await page.$eval(selector, el => el.hidden); - expect(hidden).withContext(`In ${browserName}`).toEqual(true); + expect(hidden).withContext(`In ${browserName}`).toBeTrue(); await page.focus(getAnnotationSelector("20R")); await page.keyboard.press("Enter"); @@ -651,7 +651,7 @@ describe("ResetForm action", () => { `document.querySelector('${selector}').hidden !== false` ); hidden = await page.$eval(selector, el => el.hidden); - expect(hidden).withContext(`In ${browserName}`).toEqual(true); + expect(hidden).withContext(`In ${browserName}`).toBeTrue(); await page.keyboard.press("Enter"); await page.waitForFunction( @@ -665,7 +665,7 @@ describe("ResetForm action", () => { `document.querySelector('${selector}').hidden !== false` ); hidden = await page.$eval(selector, el => el.hidden); - expect(hidden).withContext(`In ${browserName}`).toEqual(true); + expect(hidden).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -999,7 +999,7 @@ describe("RichMedia annotation", () => { const hasSource = await page.$eval(videoSelector, el => el.src.startsWith("blob:") ); - expect(hasSource).withContext(`In ${browserName}`).toEqual(true); + expect(hasSource).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -1020,7 +1020,7 @@ describe("RichMedia annotation", () => { const hasSource = await page.$eval(audioSelector, el => el.src.startsWith("blob:") ); - expect(hasSource).withContext(`In ${browserName}`).toEqual(true); + expect(hasSource).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -1056,7 +1056,7 @@ describe("Screen annotation (rendition)", () => { const hasSource = await page.$eval(videoSelector, el => el.src.startsWith("blob:") ); - expect(hasSource).withContext(`In ${browserName}`).toEqual(true); + expect(hasSource).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -1075,7 +1075,7 @@ describe("Screen annotation (rendition)", () => { const hasSource = await page.$eval(audioSelector, el => el.src.startsWith("blob:") ); - expect(hasSource).withContext(`In ${browserName}`).toEqual(true); + expect(hasSource).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -1111,7 +1111,7 @@ describe("Sound annotation", () => { const hasSource = await page.$eval(audioSelector, el => el.src.startsWith("blob:") ); - expect(hasSource).withContext(`In ${browserName}`).toEqual(true); + expect(hasSource).withContext(`In ${browserName}`).toBeTrue(); }) ); }); diff --git a/test/integration/copy_paste_spec.mjs b/test/integration/copy_paste_spec.mjs index 622d817b1..e8aef31d3 100644 --- a/test/integration/copy_paste_spec.mjs +++ b/test/integration/copy_paste_spec.mjs @@ -76,60 +76,60 @@ describe("Copy and paste", () => { text.includes("This section provides an overview of our system") ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect( text.includes( "are represented by function calls. This makes the LIR used by" ) ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect( text.includes("When compiling loops, we consult the oracle before") ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect(text.includes("Nested Trace Tree Formation")) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect( text.includes( "An important detail is that the call to the inner trace" ) ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect(text.includes("When trace recording is completed, nanojit")) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect( text.includes( "SpiderMonkey, like many VMs, needs to preempt the user program" ) ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect( text.includes( "Using similar computations, we find that trace recording takes" ) ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect( text.includes( "specialization algorithm. We also described our trace compiler" ) ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect( text.includes( "dynamic optimization system. In Proceedings of the ACM SIGPLAN" ) ) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); }) ); }); diff --git a/test/integration/freetext_editor_spec.mjs b/test/integration/freetext_editor_spec.mjs index 3bc25fa66..263b622a4 100644 --- a/test/integration/freetext_editor_spec.mjs +++ b/test/integration/freetext_editor_spec.mjs @@ -278,7 +278,7 @@ describe("FreeText Editor", () => { sel => !!document.querySelector(sel), editorSelector ); - expect(hasEditor).withContext(`In ${browserName}`).toEqual(true); + expect(hasEditor).withContext(`In ${browserName}`).toBeTrue(); } await waitForStorageEntries(page, 3); @@ -667,7 +667,7 @@ describe("FreeText Editor", () => { ); expect(newAriaOwns.endsWith("_0-editor")) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); }) ); }); @@ -1389,7 +1389,7 @@ describe("FreeText Editor", () => { let height = bbox[3] - bbox[1]; expect(width < height) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); await page.evaluate(() => { window.PDFViewerApplication.rotatePages(270); @@ -1439,7 +1439,7 @@ describe("FreeText Editor", () => { height = bbox[3] - bbox[1]; expect(width < height) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); }) ); }); @@ -1624,7 +1624,7 @@ describe("FreeText Editor", () => { .withContext( `In ${browserName}, first pix coords in editor: ${editorFirstPix} and in annotation: ${annotationFirstPix}` ) - .toEqual(true); + .toBeTrue(); } }) ); @@ -1792,7 +1792,7 @@ describe("FreeText Editor", () => { .withContext( `In ${browserName}, first pix coords in editor: ${editorFirstPix} and in annotation: ${annotationFirstPix}` ) - .toEqual(true); + .toBeTrue(); } }) ); diff --git a/test/integration/highlight_editor_spec.mjs b/test/integration/highlight_editor_spec.mjs index 7366ee7d4..44efe0743 100644 --- a/test/integration/highlight_editor_spec.mjs +++ b/test/integration/highlight_editor_spec.mjs @@ -667,10 +667,10 @@ describe("Highlight Editor", () => { // layer we can't be sure of the dimensions. expect(Math.abs(w - 73) <= 2) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); expect(Math.abs(h - 9) <= 2) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); }) ); }); @@ -745,16 +745,16 @@ describe("Highlight Editor", () => { expect(Math.abs(rectDiv.x - rectSVG.x) <= 2) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); expect(Math.abs(rectDiv.y - rectSVG.y) <= 2) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); expect(Math.abs(rectDiv.height - rectSVG.height) <= 2) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); expect(Math.abs(rectDiv.width - rectSVG.width) <= 2) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); }) ); }); @@ -889,7 +889,7 @@ describe("Highlight Editor", () => { .toBeFalse(); expect(editingEvent.hasSelectedText) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); // Click somewhere to unselect the current selection. await page.mouse.click(rect.x + rect.width + 10, y, { count: 1 }); diff --git a/test/integration/scripting_spec.mjs b/test/integration/scripting_spec.mjs index 7fdeece19..88a5886d6 100644 --- a/test/integration/scripting_spec.mjs +++ b/test/integration/scripting_spec.mjs @@ -251,7 +251,7 @@ describe("Interaction", () => { await page.type(getSelector("405R"), "employee"); let checked = await page.$eval(getSelector("449R"), el => el.checked); - expect(checked).toEqual(true); + expect(checked).toBeTrue(); // click on reset button await page.click(getAnnotationSelector("402R")); @@ -1888,15 +1888,13 @@ describe("Interaction", () => { `${selector} > canvas`, elem => getComputedStyle(elem).display !== "none" ); - expect(hasVisibleCanvas) - .withContext(`In ${browserName}`) - .toEqual(true); + expect(hasVisibleCanvas).withContext(`In ${browserName}`).toBeTrue(); const hasHiddenInput = await page.$eval( `${selector} > input`, elem => getComputedStyle(elem).display === "none" ); - expect(hasHiddenInput).withContext(`In ${browserName}`).toEqual(true); + expect(hasHiddenInput).withContext(`In ${browserName}`).toBeTrue(); await page.click(getSelector("12R")); await page.waitForFunction( @@ -1911,17 +1909,13 @@ describe("Interaction", () => { `${selector} > canvas`, elem => getComputedStyle(elem).display === "none" ); - expect(hasHiddenCanvas) - .withContext(`In ${browserName}`) - .toEqual(true); + expect(hasHiddenCanvas).withContext(`In ${browserName}`).toBeTrue(); const hasVisibleInput = await page.$eval( `${selector} > input`, elem => getComputedStyle(elem).display !== "none" ); - expect(hasVisibleInput) - .withContext(`In ${browserName}`) - .toEqual(true); + expect(hasVisibleInput).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -2006,17 +2000,17 @@ describe("Interaction", () => { getSelector("353R"), el => el.disabled ); - expect(readonly).withContext(`In ${browserName}`).toEqual(true); + expect(readonly).withContext(`In ${browserName}`).toBeTrue(); await page.click(getSelector("334R")); await waitForSandboxTrip(page); readonly = await page.$eval(getSelector("353R"), el => el.disabled); - expect(readonly).withContext(`In ${browserName}`).toEqual(true); + expect(readonly).withContext(`In ${browserName}`).toBeTrue(); await page.click(getSelector("351R")); await waitForSandboxTrip(page); readonly = await page.$eval(getSelector("353R"), el => el.disabled); - expect(readonly).withContext(`In ${browserName}`).toEqual(true); + expect(readonly).withContext(`In ${browserName}`).toBeTrue(); await page.click(getSelector("352R")); await page.waitForFunction( `${getQuerySelector("353R")}.disabled !== true` @@ -2031,7 +2025,7 @@ describe("Interaction", () => { ); let checked = await page.$eval(getSelector("353R"), el => el.checked); - expect(checked).withContext(`In ${browserName}`).toEqual(true); + expect(checked).withContext(`In ${browserName}`).toBeTrue(); await page.click(getSelector("334R")); await page.waitForFunction( `${getQuerySelector("353R")}.disabled !== false` @@ -2041,7 +2035,7 @@ describe("Interaction", () => { ); readonly = await page.$eval(getSelector("353R"), el => el.disabled); - expect(readonly).withContext(`In ${browserName}`).toEqual(true); + expect(readonly).withContext(`In ${browserName}`).toBeTrue(); checked = await page.$eval(getSelector("353R"), el => el.checked); expect(checked).withContext(`In ${browserName}`).toBeFalse(); }) @@ -2739,8 +2733,8 @@ describe("Interaction", () => { expect(value) .withContext(`In ${browserName}`) .toEqual("Hello PDF.js"); - expect(isFieldVisible).withContext(`In ${browserName}`).toBe(true); - expect(isCanvasHidden).withContext(`In ${browserName}`).toBe(true); + expect(isFieldVisible).withContext(`In ${browserName}`).toBeTrue(); + expect(isCanvasHidden).withContext(`In ${browserName}`).toBeTrue(); }) ); }); diff --git a/test/integration/stamp_editor_spec.mjs b/test/integration/stamp_editor_spec.mjs index cfeec925e..c32da068f 100644 --- a/test/integration/stamp_editor_spec.mjs +++ b/test/integration/stamp_editor_spec.mjs @@ -555,10 +555,10 @@ describe("Stamp Editor", () => { let [newWidth, newHeight] = await getDims(); expect(newWidth > width + 30) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect(newHeight > height + 30) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); for (let i = 0; i < 4; i++) { await kbBigMoveRight(page); @@ -569,10 +569,10 @@ describe("Stamp Editor", () => { [newWidth, newHeight] = await getDims(); expect(Math.abs(newWidth - width) < 2) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); expect(Math.abs(newHeight - height) < 2) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); // Move the focus to the next resizer. await page.keyboard.press("Tab"); @@ -589,7 +589,7 @@ describe("Stamp Editor", () => { [, newHeight] = await getDims(); expect(newHeight > height + 50) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); for (let i = 0; i < 4; i++) { await kbBigMoveDown(page); @@ -600,7 +600,7 @@ describe("Stamp Editor", () => { [, newHeight] = await getDims(); expect(Math.abs(newHeight - height) < 2) .withContext(`In ${browserName}`) - .toEqual(true); + .toBeTrue(); // Escape should remove the focus from the resizer. await page.keyboard.press("Escape"); diff --git a/test/integration/text_layer_images_spec.mjs b/test/integration/text_layer_images_spec.mjs index cc8fe8416..88607f2d5 100644 --- a/test/integration/text_layer_images_spec.mjs +++ b/test/integration/text_layer_images_spec.mjs @@ -95,7 +95,7 @@ describe("Text layer images", () => { }, imageCanvas) ) .withContext(`Image is not all the same pixel, in ${browserName}`) - .toBe(true); + .toBeTrue(); }) ); }); diff --git a/test/integration/viewer_spec.mjs b/test/integration/viewer_spec.mjs index b9b65d9dd..4ef44035a 100644 --- a/test/integration/viewer_spec.mjs +++ b/test/integration/viewer_spec.mjs @@ -66,7 +66,7 @@ describe("PDF viewer", () => { ); expect(attachmentsEnabled) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); // Switch to the attachments view. await page.click("#attachmentsViewMenu"); @@ -85,7 +85,7 @@ describe("PDF viewer", () => { ); return !!textLayer && !!canvas; }); - expect(stillRendered).withContext(`In ${browserName}`).toBe(true); + expect(stillRendered).withContext(`In ${browserName}`).toBeTrue(); }) ); }); @@ -221,7 +221,7 @@ describe("PDF viewer", () => { ); expect(scrollTop < 100) .withContext(`In ${browserName}`) - .toBe(true); + .toBeTrue(); } }) ); @@ -486,7 +486,7 @@ describe("PDF viewer", () => { expect(buffer.every(x => x === 0xff0000ff)) .withContext(`In ${browserName}, in the ${i}th zoom in`) - .toBe(true); + .toBeTrue(); const currentScale = await page.evaluate( () => window.PDFViewerApplication.pdfViewer.currentScale @@ -834,7 +834,7 @@ describe("PDF viewer", () => { detailCanvasSelector ); - expect(isSame).withContext(`In ${browserName}`).toBe(true); + expect(isSame).withContext(`In ${browserName}`).toBeTrue(); expect(rendered).withContext(`In ${browserName}`).toBeFalse(); }); }); diff --git a/test/unit/annotation_spec.js b/test/unit/annotation_spec.js index 3f9ba3c17..6c6c8250c 100644 --- a/test/unit/annotation_spec.js +++ b/test/unit/annotation_spec.js @@ -378,9 +378,9 @@ describe("annotation", function () { }); annotation.setFlags(13); - expect(annotation.hasFlag(AnnotationFlag.INVISIBLE)).toEqual(true); - expect(annotation.hasFlag(AnnotationFlag.NOZOOM)).toEqual(true); - expect(annotation.hasFlag(AnnotationFlag.PRINT)).toEqual(true); + expect(annotation.hasFlag(AnnotationFlag.INVISIBLE)).toBeTrue(); + expect(annotation.hasFlag(AnnotationFlag.NOZOOM)).toBeTrue(); + expect(annotation.hasFlag(AnnotationFlag.PRINT)).toBeTrue(); expect(annotation.hasFlag(AnnotationFlag.READONLY)).toBeFalse(); expect(annotation.hasFlag(AnnotationFlag.HIDDEN)).toBeFalse(); }); @@ -393,7 +393,7 @@ describe("annotation", function () { evaluatorOptions: pdfManagerMock.evaluatorOptions, }); - expect(annotation.viewable).toEqual(true); + expect(annotation.viewable).toBeTrue(); expect(annotation.printable).toBeFalse(); }); @@ -1060,7 +1060,7 @@ describe("annotation", function () { expect(data.url).toBeUndefined(); expect(data.unsafeUrl).toEqual("../../0013/001346/134685E.pdf#4.3"); expect(data.dest).toBeUndefined(); - expect(data.newWindow).toEqual(true); + expect(data.newWindow).toBeTrue(); } ); @@ -1210,7 +1210,7 @@ describe("annotation", function () { ); expect(data.unsafeUrl).toEqual("Part II/Part II.pdf"); expect(data.dest).toBeUndefined(); - expect(data.newWindow).toEqual(true); + expect(data.newWindow).toBeTrue(); } ); @@ -1653,9 +1653,9 @@ describe("annotation", function () { expect(data.annotationType).toEqual(AnnotationType.WIDGET); expect(data.textAlignment).toEqual(1); expect(data.maxLen).toEqual(20); - expect(data.readOnly).toEqual(true); + expect(data.readOnly).toBeTrue(); expect(data.hidden).toBeFalse(); - expect(data.multiLine).toEqual(true); + expect(data.multiLine).toBeTrue(); }); it("should reject comb fields without a maximum length", async function () { @@ -1688,7 +1688,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.comb).toEqual(true); + expect(data.comb).toBeTrue(); }); it("should only accept comb fields when the flags are valid", async function () { @@ -2560,7 +2560,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.checkBox).toEqual(true); + expect(data.checkBox).toBeTrue(); expect(data.fieldValue).toEqual("Checked"); expect(data.defaultFieldValue).toEqual("Off"); expect(data.radioButton).toBeFalse(); @@ -2594,7 +2594,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.checkBox).toEqual(true); + expect(data.checkBox).toBeTrue(); expect(data.radioButton).toBeFalse(); expect(data.exportValue).toEqual("I Agree to terms"); expect(data.fieldValue).toEqual("I Agree to terms"); @@ -2634,7 +2634,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.checkBox).toEqual(true); + expect(data.checkBox).toBeTrue(); expect(data.radioButton).toBeFalse(); expect(data.exportValue).toEqual("I Agree to terms"); expect(data.fieldValue).toEqual("I Agree to terms"); @@ -2657,7 +2657,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.checkBox).toEqual(true); + expect(data.checkBox).toBeTrue(); expect(data.fieldValue).toEqual("Checked"); expect(data.defaultFieldValue).toEqual("Off"); expect(data.radioButton).toBeFalse(); @@ -2686,7 +2686,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.checkBox).toEqual(true); + expect(data.checkBox).toBeTrue(); expect(data.fieldValue).toEqual("Checked"); expect(data.defaultFieldValue).toEqual("Off"); expect(data.radioButton).toBeFalse(); @@ -2772,7 +2772,7 @@ describe("annotation", function () { idFactoryMock ); - expect(annotation.data.checkBox).toEqual(true); + expect(annotation.data.checkBox).toBeTrue(); expect(annotation.data.exportValue).toEqual("Checked"); const { opList } = await annotation.getOperatorList( @@ -2788,7 +2788,7 @@ describe("annotation", function () { expect(opList.fnArray).toContain(OPS.showText); const [id, , , , isUsingOwnCanvas, canvasName] = opList.argsArray[0]; expect(id).toEqual("124R"); - expect(isUsingOwnCanvas).toEqual(true); + expect(isUsingOwnCanvas).toBeTrue(); expect(canvasName).toEqual("checked"); }); @@ -3124,7 +3124,7 @@ describe("annotation", function () { ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); expect(data.checkBox).toBeFalse(); - expect(data.radioButton).toEqual(true); + expect(data.radioButton).toBeTrue(); expect(data.fieldValue).toEqual("1"); expect(data.buttonValue).toEqual("2"); }); @@ -3156,7 +3156,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.radioButton).toEqual(true); + expect(data.radioButton).toBeTrue(); // The field value (parent "V" = "1") and this widget's own on-state ("2") // are both mapped through "Opt" to their real export values. expect(data.fieldValue).toEqual("Banane"); @@ -3190,7 +3190,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.radioButton).toEqual(true); + expect(data.radioButton).toBeTrue(); expect(data.fieldValue).toEqual("02"); expect(data.buttonValue).toEqual("02"); }); @@ -3244,7 +3244,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.radioButton).toEqual(true); + expect(data.radioButton).toBeTrue(); expect(data.fieldValue).toEqual("Banane"); expect(data.buttonValue).toEqual("Cherry"); }); @@ -3277,7 +3277,7 @@ describe("annotation", function () { ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); expect(data.checkBox).toBeFalse(); - expect(data.radioButton).toEqual(true); + expect(data.radioButton).toBeTrue(); expect(data.fieldValue).toEqual(name); expect(data.buttonValue).toEqual(name); }); @@ -3305,7 +3305,7 @@ describe("annotation", function () { ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); expect(data.checkBox).toBeFalse(); - expect(data.radioButton).toEqual(true); + expect(data.radioButton).toBeTrue(); expect(data.fieldValue).toBeNull(); expect(data.buttonValue).toEqual("2"); }); @@ -3727,7 +3727,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.pushButton).toEqual(true); + expect(data.pushButton).toBeTrue(); expect(data.actions.Action).toEqual(["do_something();"]); }); @@ -3747,7 +3747,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.pushButton).toEqual(true); + expect(data.pushButton).toBeTrue(); expect(data.alternativeText).toEqual("An alternative text"); }); @@ -4055,10 +4055,10 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.WIDGET); - expect(data.readOnly).toEqual(true); + expect(data.readOnly).toBeTrue(); expect(data.hidden).toBeFalse(); - expect(data.combo).toEqual(true); - expect(data.multiSelect).toEqual(true); + expect(data.combo).toBeTrue(); + expect(data.multiSelect).toBeTrue(); }); it("should render choice for printing", async function () { @@ -4834,7 +4834,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.RICHMEDIA); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); @@ -4906,7 +4906,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.RICHMEDIA); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); @@ -4943,7 +4943,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.RICHMEDIA); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); }); @@ -5185,7 +5185,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.SCREEN); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); @@ -5216,7 +5216,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.SCREEN); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); @@ -5236,7 +5236,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.SCREEN); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); }); @@ -5300,7 +5300,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.SOUND); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); @@ -5324,7 +5324,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.SOUND); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); @@ -5339,7 +5339,7 @@ describe("annotation", function () { idFactoryMock ); expect(data.annotationType).toEqual(AnnotationType.SOUND); - expect(data.noHTML).toEqual(true); + expect(data.noHTML).toBeTrue(); expect(data.richMedia).toBeUndefined(); }); @@ -5366,7 +5366,7 @@ describe("annotation", function () { try { catalog.attachmentContent(soundId); - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (ex) { expect(ex).toBeInstanceOf(PasswordException); expect(ex.code).toEqual(PasswordResponses.NEED_PASSWORD); @@ -5454,7 +5454,7 @@ describe("annotation", function () { // e.g., the API. expect(data.annotationFlags).toEqual(56); // The popup should inherit the `viewable` property of the parent. - expect(viewable).toEqual(true); + expect(viewable).toBeTrue(); } ); diff --git a/test/unit/annotation_storage_spec.js b/test/unit/annotation_storage_spec.js index 8f1b8ca9f..13395b356 100644 --- a/test/unit/annotation_storage_spec.js +++ b/test/unit/annotation_storage_spec.js @@ -72,11 +72,11 @@ describe("AnnotationStorage", function () { annotationStorage.onSetModified = callback; annotationStorage.setValue("asdf", { value: "original" }); - expect(called).toBe(true); + expect(called).toBeTrue(); // changing value annotationStorage.setValue("asdf", { value: "modified" }); - expect(called).toBe(true); + expect(called).toBeTrue(); // not changing value called = false; @@ -95,7 +95,7 @@ describe("AnnotationStorage", function () { annotationStorage.onResetModified = callback; annotationStorage.setValue("asdf", { value: "original" }); annotationStorage.resetModified(); - expect(called).toBe(true); + expect(called).toBeTrue(); called = false; // not changing value @@ -106,7 +106,7 @@ describe("AnnotationStorage", function () { // changing value annotationStorage.setValue("asdf", { value: "modified" }); annotationStorage.resetModified(); - expect(called).toBe(true); + expect(called).toBeTrue(); }); }); }); diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index aff44a4db..4f96ff60e 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -261,9 +261,9 @@ describe("api", function () { await loadingTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch { - expect(true).toEqual(true); + expect(true).toBeTrue(); await destroyed; } }); @@ -394,7 +394,7 @@ describe("api", function () { await loadingTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(InvalidPDFException); expect(reason.message).toEqual("Invalid PDF structure."); @@ -413,11 +413,11 @@ describe("api", function () { await loadingTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(ResponseException); expect(reason.status).toEqual(isNodeJS ? 0 : 404); - expect(reason.missing).toEqual(true); + expect(reason.missing).toBeTrue(); } await loadingTask.destroy(); @@ -459,7 +459,7 @@ describe("api", function () { return; } // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }; const data = await Promise.all([ @@ -485,7 +485,7 @@ describe("api", function () { const result1 = passwordNeededLoadingTask.promise.then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); throw new Error("loadingTask should be rejected"); }, function (data) { @@ -507,7 +507,7 @@ describe("api", function () { const result2 = passwordIncorrectLoadingTask.promise.then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); throw new Error("loadingTask should be rejected"); }, function (data) { @@ -563,12 +563,12 @@ describe("api", function () { return; } // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }; const result1 = passwordNeededLoadingTask.promise.then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); throw new Error("loadingTask should be rejected"); }, function (reason) { @@ -583,12 +583,12 @@ describe("api", function () { throw new Error("Incorrect password"); } // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }; const result2 = passwordIncorrectLoadingTask.promise.then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); throw new Error("loadingTask should be rejected"); }, function (reason) { @@ -622,7 +622,7 @@ describe("api", function () { await loadingTask.promise.then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }, function (reason) { expect(reason).toBeInstanceOf(PasswordException); @@ -642,7 +642,7 @@ describe("api", function () { await loadingTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(InvalidPDFException); expect(reason.message).toEqual( @@ -705,7 +705,7 @@ describe("api", function () { const opList = await page.getOperatorList(); expect(opList.fnArray.length).toEqual(0); expect(opList.argsArray.length).toEqual(0); - expect(opList.lastChunk).toEqual(true); + expect(opList.lastChunk).toBeTrue(); expect(opList.separateAnnots).toBeNull(); await loadingTask.destroy(); @@ -726,7 +726,7 @@ describe("api", function () { const opList = await page.getOperatorList(); expect(opList.fnArray.length).toEqual(0); expect(opList.argsArray.length).toEqual(0); - expect(opList.lastChunk).toEqual(true); + expect(opList.lastChunk).toBeTrue(); expect(opList.separateAnnots).toBeNull(); await loadingTask.destroy(); @@ -743,7 +743,7 @@ describe("api", function () { await loadingTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(InvalidPDFException); expect(reason.message).toEqual("Invalid Root reference."); @@ -762,7 +762,7 @@ describe("api", function () { await loadingTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(InvalidPDFException); expect(reason.message).toEqual("Invalid Root reference."); @@ -800,7 +800,7 @@ describe("api", function () { const opListA = await pageA.getOperatorList(); expect(opListA.fnArray.length).toBeGreaterThan(5); expect(opListA.argsArray.length).toBeGreaterThan(5); - expect(opListA.lastChunk).toEqual(true); + expect(opListA.lastChunk).toBeTrue(); expect(opListA.separateAnnots).toBeNull(); const pageB = await pdfDocument2.getPage(1); @@ -809,14 +809,14 @@ describe("api", function () { const opListB = await pageB.getOperatorList(); expect(opListB.fnArray.length).toBe(0); expect(opListB.argsArray.length).toBe(0); - expect(opListB.lastChunk).toEqual(true); + expect(opListB.lastChunk).toBeTrue(); expect(opListB.separateAnnots).toBeNull(); try { await pdfDocument3.getPage(1); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(UnknownErrorException); expect(reason.message).toEqual("Bad (uncompressed) XRef entry: 3R"); @@ -850,7 +850,7 @@ describe("api", function () { const opListA = await pageA.getOperatorList(); expect(opListA.fnArray.length).toEqual(19); expect(opListA.argsArray.length).toEqual(19); - expect(opListA.lastChunk).toEqual(true); + expect(opListA.lastChunk).toBeTrue(); expect(opListA.separateAnnots).toBeNull(); const pageB = await pdfDocument2.getPage(1); @@ -859,7 +859,7 @@ describe("api", function () { const opListB = await pageB.getOperatorList(); expect(opListB.fnArray.length).toEqual(1); expect(opListB.argsArray.length).toEqual(1); - expect(opListB.lastChunk).toEqual(true); + expect(opListB.lastChunk).toBeTrue(); expect(opListB.separateAnnots).toBeNull(); await Promise.all([loadingTask1.destroy(), loadingTask2.destroy()]); @@ -893,7 +893,7 @@ describe("api", function () { ]) { expect(opList.fnArray.length).toBeGreaterThan(5); expect(opList.argsArray.length).toBeGreaterThan(5); - expect(opList.lastChunk).toEqual(true); + expect(opList.lastChunk).toBeTrue(); expect(opList.separateAnnots).toBeNull(); } @@ -920,7 +920,7 @@ describe("api", function () { await pdfDocument1.getPage(1); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(UnknownErrorException); expect(reason.message).toEqual("Illegal character: 41"); @@ -929,7 +929,7 @@ describe("api", function () { await pdfDocument2.getPage(1); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(UnknownErrorException); expect(reason.message).toEqual("End of file inside array."); @@ -973,7 +973,7 @@ describe("api", function () { new Float32Array([0, 9.75, 0.5, 9.75]), ], ]); - expect(opList.lastChunk).toEqual(true); + expect(opList.lastChunk).toBeTrue(); await loadingTask.destroy(); }); @@ -1021,7 +1021,7 @@ describe("api", function () { await loadingTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (ex) { expect(ex).toBeInstanceOf(PasswordException); expect(ex.code).toEqual(PasswordResponses.NEED_PASSWORD); @@ -1061,14 +1061,14 @@ describe("api", function () { const worker = new PDFWorker({ name: "test1" }); await worker.promise; expect(worker.name).toEqual("test1"); - expect(!!worker.port).toEqual(true); + expect(!!worker.port).toBeTrue(); expect(worker.destroyed).toBeFalse(); - expect(!!worker._webWorker).toEqual(true); - expect(worker.port === worker._webWorker).toEqual(true); + expect(!!worker._webWorker).toBeTrue(); + expect(worker.port === worker._webWorker).toBeTrue(); worker.destroy(); expect(!!worker.port).toBeFalse(); - expect(worker.destroyed).toEqual(true); + expect(worker.destroyed).toBeTrue(); }); it("worker created or destroyed by getDocument", async function () { @@ -1080,7 +1080,7 @@ describe("api", function () { let worker; loadingTask.promise.then(function () { worker = loadingTask._worker; - expect(!!worker).toEqual(true); + expect(!!worker).toBeTrue(); }); const destroyPromise = loadingTask.promise.then(() => @@ -1090,7 +1090,7 @@ describe("api", function () { const destroyedWorker = loadingTask._worker; expect(!!destroyedWorker).toBeFalse(); - expect(worker.destroyed).toEqual(true); + expect(worker.destroyed).toBeTrue(); }); it("worker created and can be used in getDocument", async function () { @@ -1109,7 +1109,7 @@ describe("api", function () { expect(!!docWorker).toBeFalse(); // checking is the same port is used in the MessageHandler const messageHandlerPort = loadingTask._transport.messageHandler.comObj; - expect(messageHandlerPort === worker.port).toEqual(true); + expect(messageHandlerPort === worker.port).toBeTrue(); }); const destroyPromise = loadingTask.promise.then(() => @@ -1135,7 +1135,7 @@ describe("api", function () { worker1.port !== worker2.port && worker1.port !== worker3.port && worker2.port !== worker3.port - ).toEqual(true); + ).toBeTrue(); worker1.destroy(); worker2.destroy(); worker3.destroy(); @@ -1166,7 +1166,7 @@ describe("api", function () { "https://www.mozilla.org/foo", "https://www.mozilla.org/bar" ) - ).toEqual(true); + ).toBeTrue(); expect( PDFWorker._isSameOrigin( "https://www.mozilla.org/foo", @@ -1350,7 +1350,7 @@ describe("api", function () { await pdfDocument.getPage(pageNumber); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(Error); expect(reason.message).toEqual("Invalid page request."); @@ -1452,7 +1452,7 @@ describe("api", function () { await pdfDocument.getPageIndex(pageRefs[i]); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { const { exception, message } = expectedErrors[i]; @@ -1966,7 +1966,7 @@ describe("api", function () { const pdfDoc = await loadingTask.promise; const hasJSActions = await pdfDoc.hasJSActions(); - expect(hasJSActions).toEqual(true); + expect(hasJSActions).toBeTrue(); await loadingTask.destroy(); }); @@ -2318,18 +2318,18 @@ describe("api", function () { const outline = await pdfDocument.getOutline(); // Two top level entries. - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(2); // Make sure some basic attributes are set. const outlineItem = outline[1]; expect(outlineItem.title).toEqual("Chapter 1"); - expect(Array.isArray(outlineItem.dest)).toEqual(true); + expect(Array.isArray(outlineItem.dest)).toBeTrue(); expect(outlineItem.url).toBeNull(); expect(outlineItem.unsafeUrl).toBeUndefined(); expect(outlineItem.newWindow).toBeUndefined(); - expect(outlineItem.bold).toEqual(true); + expect(outlineItem.bold).toBeTrue(); expect(outlineItem.italic).toBeFalse(); expect(outlineItem.color).toEqual(new Uint8ClampedArray([0, 64, 128])); @@ -2341,7 +2341,7 @@ describe("api", function () { const loadingTask = getDocument(buildGetDocumentParams("issue3214.pdf")); const pdfDoc = await loadingTask.promise; const outline = await pdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(5); const outlineItemTwo = outline[2]; @@ -2353,7 +2353,7 @@ describe("api", function () { const outlineItemOne = outline[1]; expect(outlineItemOne.bold).toBeFalse(); - expect(outlineItemOne.italic).toEqual(true); + expect(outlineItemOne.italic).toBeTrue(); expect(outlineItemOne.color).toEqual(new Uint8ClampedArray([0, 0, 0])); await loadingTask.destroy(); @@ -2364,7 +2364,7 @@ describe("api", function () { const pdfDoc = await loadingTask.promise; const outline = await pdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(9); expect(outline[0]).toEqual({ @@ -2392,7 +2392,7 @@ describe("api", function () { const pdfDoc = await loadingTask.promise; const outline = await pdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(6); expect(outline[4]).toEqual({ @@ -2420,7 +2420,7 @@ describe("api", function () { const pdfDoc = await loadingTask.promise; const outline = await pdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(4); expect(outline[1]).toEqual({ @@ -2448,7 +2448,7 @@ describe("api", function () { const pdfDoc = await loadingTask.promise; const outline = await pdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(1); expect(outline[0]).toEqual({ @@ -2475,7 +2475,7 @@ describe("api", function () { const loadingTask = getDocument(buildGetDocumentParams("issue14267.pdf")); const pdfDoc = await loadingTask.promise; const outline = await pdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(1); const outlineItem = outline[0]; @@ -2725,7 +2725,7 @@ describe("api", function () { expect(info.CreationDate).toEqual("D:20090401163925-07'00'"); // Custom, non-standard, information dictionary entries. const custom = info.Custom; - expect(typeof custom === "object" && custom !== null).toEqual(true); + expect(typeof custom === "object" && custom !== null).toBeTrue(); expect(custom["PTEX.Fullbanner"]).toEqual( "This is pdfeTeX, " + @@ -2788,7 +2788,7 @@ describe("api", function () { expect(info.Language).toBeNull(); expect(info.EncryptFilterName).toBeNull(); expect(info.IsLinearized).toBeFalse(); - expect(info.IsAcroFormPresent).toEqual(true); + expect(info.IsAcroFormPresent).toBeTrue(); expect(info.IsXFAPresent).toBeFalse(); expect(info.IsCollectionPresent).toBeFalse(); expect(info.IsSignaturesPresent).toBeFalse(); @@ -2807,7 +2807,7 @@ describe("api", function () { const pdfDoc = await loadingTask.promise; const markInfo = await pdfDoc.getMarkInfo(); - expect(markInfo.Marked).toEqual(true); + expect(markInfo.Marked).toBeTrue(); expect(markInfo.UserProperties).toBeFalse(); expect(markInfo.Suspects).toBeFalse(); @@ -2851,7 +2851,7 @@ describe("api", function () { it("cleans up document resources", async function () { await pdfDocument.cleanup(); - expect(true).toEqual(true); + expect(true).toBeTrue(); }); it("checks that fingerprints are unique", async function () { @@ -2901,7 +2901,7 @@ describe("api", function () { const annotations = await pdfPage.getAnnotations(); const field = annotations.find(annotation => annotation.id === "55R"); - expect(!!field).toEqual(true); + expect(!!field).toBeTrue(); expect(field.fieldValue).toEqual(value); await loadingTask.destroy(); @@ -3613,7 +3613,7 @@ describe("api", function () { const annotations = await pdfPage.getAnnotations(); const field = annotations.find(annotation => annotation.id === "144R"); - expect(!!field).toEqual(true); + expect(!!field).toBeTrue(); expect(field.fieldValue).toEqual("Several\n\nOther\nJobs"); expect(field.textContent).toEqual(["Several", "", "Other", "Jobs"]); @@ -3638,7 +3638,7 @@ describe("api", function () { .then(() => loadingTask.destroy()) .then( function () { - expect(expectSuccess).toEqual(true); + expect(expectSuccess).toBeTrue(); }, function (error) { if (expectSuccess) { @@ -4099,7 +4099,7 @@ describe("api", function () { a => a.annotationType === AnnotationType.FILEATTACHMENT ); const { fileId } = fileAnnotation; - expect(fileId.startsWith("attachmentRef:")).toEqual(true); + expect(fileId.startsWith("attachmentRef:")).toBeTrue(); const before = await pdfDoc.getAttachmentContent(fileId); expect(before).toBeInstanceOf(Uint8Array); @@ -4129,7 +4129,7 @@ describe("api", function () { expect(unsafeUrl).toEqual( "对不起/没关系/1_1_模块1行政文件和药品信息目录.pdf" ); - expect(newWindow).toEqual(true); + expect(newWindow).toBeTrue(); await loadingTask.destroy(); }); @@ -4200,7 +4200,7 @@ page 1 / 3`); // `commonObjs` property being populated below. canvasFactory.destroy(canvasAndCtx); - expect(pdfPage.commonObjs.has(fontName)).toEqual(true); + expect(pdfPage.commonObjs.has(fontName)).toBeTrue(); await loadingTask.destroy(); }); @@ -4234,7 +4234,7 @@ page 1 / 3`); text.includes( "Engang var der i Samvirke en opskrift på en fiskelagkage, som jeg med" ) - ).toBe(true); + ).toBeTrue(); await loadingTask.destroy(); }); @@ -4252,17 +4252,17 @@ page 1 / 3`); text.includes( "Abstract. A purely peer-to-peer version of electronic cash would allow online" ) - ).toEqual(true); + ).toBeTrue(); expect( text.includes( "avoid mediating disputes. The cost of mediation increases transaction costs, limiting the" ) - ).toEqual(true); + ).toBeTrue(); expect( text.includes( "system is secure as long as honest nodes collectively control more CPU power than any" ) - ).toEqual(true); + ).toBeTrue(); await loadingTask.destroy(); }); @@ -4280,12 +4280,12 @@ page 1 / 3`); text.includes( "1. The first of these cases arises from the tragic handicap which has blighted the life of the Plaintiff, and from the response of the" ) - ).toEqual(true); + ).toBeTrue(); expect( text.includes( "argued in this Court the appeal raises narrower, but important, issues which may be summarised as follows:-" ) - ).toEqual(true); + ).toBeTrue(); await loadingTask.destroy(); }); @@ -4305,7 +4305,7 @@ page 1 / 3`); 1,485.1 1,582.7 1,629.2 1,633.7 114.2 121.7 125.3 130.7 13.0x 13.0x 13.0x 12.5x`) - ).toEqual(true); + ).toBeTrue(); await loadingTask.destroy(); }); @@ -4328,7 +4328,7 @@ This package provides support for this font in LATEX. It includes Type \x81 versions of the fonts, converted for this package using FontForge from its sources, for full support with Dvips.`; - expect(text.includes(expected)).toEqual(true); + expect(text.includes(expected)).toBeTrue(); ({ items } = await pdfPage.getTextContent({ disableNormalization: false, @@ -4343,7 +4343,7 @@ Directory [\x81] as TrueType files licensed under the Apache License version \x8 This package provides support for this font in LATEX. It includes Type \x81 versions of the fonts, converted for this package using FontForge from its sources, for full support with Dvips.`; - expect(text.includes(expected)).toEqual(true); + expect(text.includes(expected)).toBeTrue(); await loadingTask.destroy(); }); @@ -4369,7 +4369,7 @@ Innovationsabteilung. Seit 2009 ist sie Frank Stronachs Büroleiterin in Österr Kanada. Zusätzlich ist sie seit 2012 Vice President, Business Development der Stronach Group und Vizepräsidentin und Institutsleiterin des Stronach Institut für sozialökonomische Gerechtigkeit.`) - ).toEqual(true); + ).toBeTrue(); await loadingTask.destroy(); }); @@ -4390,7 +4390,7 @@ FAMILY TRUST /u/a dated October 31, 1980 as amended, and STUART W. EPPERSON, not individually but solely as Trustee of the STUART W. EPPERSON REVOCABLE LIVING TRUST /u/a dated January 14th 1993 as amended, collectively referred to herein as “Lessor”, and Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`) - ).toEqual(true); + ).toBeTrue(); await loadingTask.destroy(); }); @@ -4525,7 +4525,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`) // No item should carry a hasEOL flag between the superscript and the // text that follows it. - expect(items.every(i => !i.hasEOL)).toEqual(true); + expect(items.every(i => !i.hasEOL)).toBeTrue(); // Full sentence must be reconstructable without a newline. const text = mergeText(items); @@ -4872,7 +4872,7 @@ have written that much by now. So, here’s to squashing bugs.`); expect(operatorList.fnArray.length).toBeGreaterThan(100); expect(operatorList.argsArray.length).toBeGreaterThan(100); - expect(operatorList.lastChunk).toEqual(true); + expect(operatorList.lastChunk).toBeTrue(); expect(operatorList.separateAnnots).toEqual({ form: false, canvas: false, @@ -4921,7 +4921,7 @@ have written that much by now. So, here’s to squashing bugs.`); expect(opList.fnArray.length).toBeGreaterThan(100); expect(opList.argsArray.length).toBeGreaterThan(100); - expect(opList.lastChunk).toEqual(true); + expect(opList.lastChunk).toBeTrue(); expect(opList.separateAnnots).toBeNull(); await loadingTask1.destroy(); @@ -4933,7 +4933,7 @@ have written that much by now. So, here’s to squashing bugs.`); expect(opList.fnArray.length).toEqual(0); expect(opList.argsArray.length).toEqual(0); - expect(opList.lastChunk).toEqual(true); + expect(opList.lastChunk).toBeTrue(); expect(opList.separateAnnots).toBeNull(); await loadingTask2.destroy(); @@ -4951,7 +4951,7 @@ have written that much by now. So, here’s to squashing bugs.`); const pdfPage = await pdfDoc.getPage(1); const operatorList = await pdfPage.getOperatorList(); - expect(operatorList.lastChunk).toEqual(true); + expect(operatorList.lastChunk).toBeTrue(); await loadingTask.destroy(); }); @@ -4966,7 +4966,7 @@ have written that much by now. So, here’s to squashing bugs.`); expect(operatorList.fnArray.length).toBeGreaterThan(20); expect(operatorList.argsArray.length).toBeGreaterThan(20); - expect(operatorList.lastChunk).toEqual(true); + expect(operatorList.lastChunk).toBeTrue(); expect(operatorList.separateAnnots).toEqual({ form: false, canvas: false, @@ -4974,8 +4974,8 @@ have written that much by now. So, here’s to squashing bugs.`); // The `getOperatorList` method, similar to the `render` method, // is supposed to include any existing Annotation-operatorLists. - expect(operatorList.fnArray.includes(OPS.beginAnnotation)).toEqual(true); - expect(operatorList.fnArray.includes(OPS.endAnnotation)).toEqual(true); + expect(operatorList.fnArray.includes(OPS.beginAnnotation)).toBeTrue(); + expect(operatorList.fnArray.includes(OPS.endAnnotation)).toBeTrue(); await loadingTask.destroy(); }); @@ -4993,7 +4993,7 @@ have written that much by now. So, here’s to squashing bugs.`); }); expect(opListAnnotDisable.fnArray.length).toEqual(0); expect(opListAnnotDisable.argsArray.length).toEqual(0); - expect(opListAnnotDisable.lastChunk).toEqual(true); + expect(opListAnnotDisable.lastChunk).toBeTrue(); expect(opListAnnotDisable.separateAnnots).toBeNull(); const opListAnnotEnable = await pdfPage.getOperatorList({ @@ -5001,7 +5001,7 @@ have written that much by now. So, here’s to squashing bugs.`); }); expect(opListAnnotEnable.fnArray.length).toBeGreaterThan(130); expect(opListAnnotEnable.argsArray.length).toBeGreaterThan(130); - expect(opListAnnotEnable.lastChunk).toEqual(true); + expect(opListAnnotEnable.lastChunk).toBeTrue(); expect(opListAnnotEnable.separateAnnots).toEqual({ form: false, canvas: true, @@ -5018,7 +5018,7 @@ have written that much by now. So, here’s to squashing bugs.`); }); expect(opListAnnotEnableForms.fnArray.length).toBeGreaterThan(30); expect(opListAnnotEnableForms.argsArray.length).toBeGreaterThan(30); - expect(opListAnnotEnableForms.lastChunk).toEqual(true); + expect(opListAnnotEnableForms.lastChunk).toBeTrue(); expect(opListAnnotEnableForms.separateAnnots).toEqual({ form: true, canvas: true, @@ -5028,14 +5028,14 @@ have written that much by now. So, here’s to squashing bugs.`); OPS.beginAnnotation ); isUsingOwnCanvas = opListAnnotEnableForms.argsArray[firstAnnotIndex][4]; - expect(isUsingOwnCanvas).toEqual(true); + expect(isUsingOwnCanvas).toBeTrue(); const opListAnnotEnableStorage = await pdfPage.getOperatorList({ annotationMode: AnnotationMode.ENABLE_STORAGE, }); expect(opListAnnotEnableStorage.fnArray.length).toBeGreaterThan(150); expect(opListAnnotEnableStorage.argsArray.length).toBeGreaterThan(150); - expect(opListAnnotEnableStorage.lastChunk).toEqual(true); + expect(opListAnnotEnableStorage.lastChunk).toBeTrue(); expect(opListAnnotEnableStorage.separateAnnots).toEqual({ form: false, canvas: true, @@ -5076,7 +5076,7 @@ have written that much by now. So, here’s to squashing bugs.`); const opList = await pdfPage.getOperatorList(); expect(opList.fnArray.length).toBeGreaterThan(25); expect(opList.argsArray.length).toBeGreaterThan(25); - expect(opList.lastChunk).toEqual(true); + expect(opList.lastChunk).toBeTrue(); await loadingTask.destroy(); }); @@ -5188,7 +5188,7 @@ have written that much by now. So, here’s to squashing bugs.`); await renderTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(RenderingCancelledException); expect(reason.message).toEqual("Rendering cancelled, page 1"); @@ -5219,7 +5219,7 @@ have written that much by now. So, here’s to squashing bugs.`); await renderTask.promise; // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(RenderingCancelledException); } @@ -5267,11 +5267,11 @@ have written that much by now. So, here’s to squashing bugs.`); renderTask2.promise.then( () => { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }, reason => { // It fails because we are already using this canvas. - expect(/multiple render\(\)/.test(reason.message)).toEqual(true); + expect(/multiple render\(\)/.test(reason.message)).toBeTrue(); } ), ]); @@ -5302,7 +5302,7 @@ have written that much by now. So, here’s to squashing bugs.`); expect(renderTask.separateAnnots).toBeFalse(); await pdfDoc.cleanup(); - expect(true).toEqual(true); + expect(true).toBeTrue(); canvasFactory.destroy(canvasAndCtx); await loadingTask.destroy(); @@ -5337,7 +5337,7 @@ have written that much by now. So, here’s to squashing bugs.`); await pdfDoc.cleanup(); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(Error); expect(reason.message).toEqual( @@ -5397,7 +5397,7 @@ have written that much by now. So, here’s to squashing bugs.`); if (i < NUM_PAGES_THRESHOLD) { expect(objId).toEqual(`img_p${i - 1}_1`); - expect(objs.has(objId)).toEqual(true); + expect(objs.has(objId)).toBeTrue(); expect(commonObjs.has(objId)).toBeFalse(); } else { expect(objId).toEqual( @@ -5405,7 +5405,7 @@ have written that much by now. So, here’s to squashing bugs.`); ); expect(objs.has(objId)).toBeFalse(); - expect(commonObjs.has(objId)).toEqual(true); + expect(commonObjs.has(objId)).toBeTrue(); } expect(width).toEqual(EXPECTED_WIDTH); expect(height).toEqual(EXPECTED_HEIGHT); @@ -5477,11 +5477,11 @@ have written that much by now. So, here’s to squashing bugs.`); if (i < NUM_PAGES_THRESHOLD) { // Image decoded in the worker-thread; stored as a page-level object. - expect(objs.has(objId)).toEqual(true); + expect(objs.has(objId)).toBeTrue(); expect(commonObjs.has(objId)).toBeFalse(); } else if (i === NUM_PAGES_THRESHOLD) { expect(objs.has(objId)).toBeFalse(); - expect(commonObjs.has(objId)).toEqual(true); + expect(commonObjs.has(objId)).toBeTrue(); // Ensure that the image was copied in the main-thread (into // commonObjs), rather than being re-parsed in the worker-thread. @@ -5530,7 +5530,7 @@ have written that much by now. So, here’s to squashing bugs.`); if (i < NUM_PAGES_THRESHOLD) { expect(objId).toEqual(`img_p${i - 1}_1`); - expect(objs.has(objId)).toEqual(true); + expect(objs.has(objId)).toBeTrue(); expect(commonObjs.has(objId)).toBeFalse(); } else { expect(objId).toEqual( @@ -5538,7 +5538,7 @@ have written that much by now. So, here’s to squashing bugs.`); ); expect(objs.has(objId)).toBeFalse(); - expect(commonObjs.has(objId)).toEqual(true); + expect(commonObjs.has(objId)).toBeTrue(); } // Ensure that the actual image data is identical for all pages. @@ -5645,7 +5645,7 @@ have written that much by now. So, here’s to squashing bugs.`); canvasAndCtx.context .getImageData(0, 0, viewport.width, viewport.height) .data.some(channel => channel !== 0) - ).toEqual(true); + ).toBeTrue(); canvasFactory.destroy(canvasAndCtx); await loadingTask.destroy(); @@ -7881,7 +7881,7 @@ small scripts as well as for`); pdfDoc = await loadingTask.promise; const calculationOrder = await pdfDoc.getCalculationOrderIds(); - expect(Array.isArray(calculationOrder)).toEqual(true); + expect(Array.isArray(calculationOrder)).toBeTrue(); expect(calculationOrder.length).toEqual(1); expect(calculationOrder[0]).not.toEqual("6R"); expect(Object.keys((await pdfDoc.getFieldObjects()) || {})).toEqual([ @@ -8054,12 +8054,12 @@ small scripts as well as for`); const newPdfDoc = await newLoadingTask.promise; const outline = await newPdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(7); // Item [0]: explicit array dest expect(outline[0].title).toEqual("Page 1 - explicit dest"); - expect(Array.isArray(outline[0].dest)).toEqual(true); + expect(Array.isArray(outline[0].dest)).toBeTrue(); expect(outline[0].dest[1].name).toEqual("XYZ"); // Item [1]: named string dest @@ -8091,15 +8091,15 @@ small scripts as well as for`); // Section 1: explicit FitH dest expect(chapter.items[0].title).toEqual("Section 1"); - expect(Array.isArray(chapter.items[0].dest)).toEqual(true); + expect(Array.isArray(chapter.items[0].dest)).toBeTrue(); expect(chapter.items[0].dest[1].name).toEqual("FitH"); // Section 2: named dest + bold + italic + red color const section2 = chapter.items[1]; expect(section2.title).toEqual("Section 2"); expect(typeof section2.dest).toEqual("string"); - expect(section2.bold).toEqual(true); - expect(section2.italic).toEqual(true); + expect(section2.bold).toBeTrue(); + expect(section2.italic).toBeTrue(); expect(section2.color).toEqual(new Uint8ClampedArray([255, 0, 0])); // Subsection: parent with own dest + one child @@ -8134,7 +8134,7 @@ small scripts as well as for`); const newPdfDoc = await newLoadingTask.promise; const outline = await newPdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); // 6 items: all except "No dest parent" (its child dest was on page 5). expect(outline.length).toEqual(6); @@ -8172,7 +8172,7 @@ small scripts as well as for`); const newPdfDoc = await newLoadingTask.promise; const outline = await newPdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); // 5 items: explicit dest (page1) and named dest (page2dest) are gone; // the 3 external-link items + "Chapter" + "No dest parent" remain. expect(outline.length).toEqual(5); @@ -8241,13 +8241,13 @@ small scripts as well as for`); expect(newPdfDoc.numPages).toEqual(2); const outline = await newPdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); // 5 items from copy A + 4 items from copy B = 9 total. expect(outline.length).toEqual(9); // ---- Copy A items ---- expect(outline[0].title).toEqual("Page 1 - explicit dest"); - expect(Array.isArray(outline[0].dest)).toEqual(true); + expect(Array.isArray(outline[0].dest)).toBeTrue(); expect(outline[1].title).toEqual("External URL"); expect(outline[2].title).toEqual("Next Page action"); expect(outline[3].title).toEqual("Remote PDF link"); @@ -8329,7 +8329,7 @@ small scripts as well as for`); expect(newPdfDoc.numPages).toEqual(2); const outline = await newPdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); // Copy A: "Page 1 - explicit dest", "External URL", "Next Page // action", "Remote PDF link", "Chapter" (dest=page1dest) // Copy B: same 5 items but "Chapter" dest is renamed. @@ -8343,7 +8343,7 @@ small scripts as well as for`); const chapterDests = chapterItems.map(i => i.dest); expect(chapterDests[0]).not.toEqual(chapterDests[1]); // One of them is the original name. - expect(chapterDests.includes("page1dest")).toEqual(true); + expect(chapterDests.includes("page1dest")).toBeTrue(); // The other is a renamed version that still exists in the doc. const renamedDest = chapterDests.find(d => d !== "page1dest"); expect(typeof renamedDest).toEqual("string"); @@ -8354,8 +8354,8 @@ small scripts as well as for`); i => i.title === "Page 1 - explicit dest" ); expect(page1Items.length).toEqual(2); - expect(Array.isArray(page1Items[0].dest)).toEqual(true); - expect(Array.isArray(page1Items[1].dest)).toEqual(true); + expect(Array.isArray(page1Items[0].dest)).toBeTrue(); + expect(Array.isArray(page1Items[1].dest)).toBeTrue(); await newLoadingTask.destroy(); }); @@ -8378,7 +8378,7 @@ small scripts as well as for`); expect(newPdfDoc.numPages).toEqual(1); const outline = await newPdfDoc.getOutline(); - expect(Array.isArray(outline)).toEqual(true); + expect(Array.isArray(outline)).toBeTrue(); expect(outline.length).toEqual(1); // "Parent" is kept as a plain container (dest cleared, no action). @@ -8390,7 +8390,7 @@ small scripts as well as for`); // "Child" keeps its explicit dest pointing to the (only) kept page. const child = parent.items[0]; expect(child.title).toEqual("Child"); - expect(Array.isArray(child.dest)).toEqual(true); + expect(Array.isArray(child.dest)).toBeTrue(); await newLoadingTask.destroy(); }); @@ -8432,7 +8432,7 @@ small scripts as well as for`); await passwordNeededLoadingTask.promise.then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }, function (err) { expect(err).toBeInstanceOf(PasswordException); diff --git a/test/unit/cff_parser_spec.js b/test/unit/cff_parser_spec.js index f368d5fa8..b46096d11 100644 --- a/test/unit/cff_parser_spec.js +++ b/test/unit/cff_parser_spec.js @@ -154,7 +154,7 @@ describe("CFFParser", function () { ]); expect(properties.ascent).toEqual(900); expect(properties.descent).toEqual(-300); - expect(properties.ascentScaled).toEqual(true); + expect(properties.ascentScaled).toBeTrue(); }); it("repairs a FontBBox with unsigned-encoded negative coordinates", function () { @@ -177,7 +177,7 @@ describe("CFFParser", function () { ]); expect(properties.ascent).toEqual(989); expect(properties.descent).toEqual(-305); - expect(properties.ascentScaled).toEqual(true); + expect(properties.ascentScaled).toBeTrue(); }); it("doesn't replace a repairable FontBBox with an empty descriptor bbox", function () { @@ -198,7 +198,7 @@ describe("CFFParser", function () { ]); expect(properties.ascent).toEqual(989); expect(properties.descent).toEqual(-305); - expect(properties.ascentScaled).toEqual(true); + expect(properties.ascentScaled).toBeTrue(); }); it("repairs unsigned-encoded negative FontBBox without descriptor data", function () { @@ -217,7 +217,7 @@ describe("CFFParser", function () { ]); expect(properties.ascent).toEqual(989); expect(properties.descent).toEqual(-305); - expect(properties.ascentScaled).toEqual(true); + expect(properties.ascentScaled).toBeTrue(); }); it("preserves large positive upper FontBBox coordinates", function () { @@ -238,7 +238,7 @@ describe("CFFParser", function () { ]); expect(properties.ascent).toEqual(989); expect(properties.descent).toEqual(-305); - expect(properties.ascentScaled).toEqual(true); + expect(properties.ascentScaled).toBeTrue(); }); it("repairs likely Ghostscript-zeroed FDArray private defaults", function () { @@ -383,7 +383,7 @@ describe("CFFParser", function () { SEAC_ANALYSIS_ENABLED ).parse(); - expect(embeddedCff.isCIDFont).toEqual(true); + expect(embeddedCff.isCIDFont).toBeTrue(); expect(embeddedCff.fdArray[0].privateDict.getByName("BlueScale")).toEqual( 0.037 ); @@ -542,7 +542,7 @@ describe("CFFParser", function () { it("parses predefined charsets", function () { const charset = parser.parseCharsets(0, 0, null, true); - expect(charset.predefined).toEqual(true); + expect(charset.predefined).toBeTrue(); }); it("parses charset format 0", function () { diff --git a/test/unit/cmap_spec.js b/test/unit/cmap_spec.js index f5e4ba991..2932dace6 100644 --- a/test/unit/cmap_spec.js +++ b/test/unit/cmap_spec.js @@ -157,7 +157,7 @@ describe("cmap", function () { const str = "/WMode 1 def\n"; const stream = new StringStream(str); const cmap = await CMapFactory.create({ encoding: stream }); - expect(cmap.vertical).toEqual(true); + expect(cmap.vertical).toBeTrue(); }); it("loads built in cmap", async function () { @@ -196,7 +196,7 @@ describe("cmap", function () { }); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(Error); expect(reason.message).toEqual("Unknown CMap name: null"); @@ -221,7 +221,7 @@ describe("cmap", function () { }); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(Error); expect(reason.message).toEqual( @@ -250,12 +250,12 @@ describe("cmap", function () { }); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(Error); const message = reason.message; - expect(message.startsWith("Unable to load CMap data at: ")).toEqual(true); - expect(message.endsWith("/external/bcmaps/Adobe-Japan1-1")).toEqual(true); + expect(message.startsWith("Unable to load CMap data at: ")).toBeTrue(); + expect(message.endsWith("/external/bcmaps/Adobe-Japan1-1")).toBeTrue(); } }); }); diff --git a/test/unit/common_pdfstream_tests.js b/test/unit/common_pdfstream_tests.js index 8a4150213..7cd4fa3f9 100644 --- a/test/unit/common_pdfstream_tests.js +++ b/test/unit/common_pdfstream_tests.js @@ -40,7 +40,7 @@ async function testCrossOriginRedirects({ await fullReader.headersReady; // Sanity check: We can only test range requests if supported: - expect(fullReader.isRangeSupported).toEqual(true); + expect(fullReader.isRangeSupported).toBeTrue(); // ^ When range requests are supported (and streaming is disabled), the full // initial request is aborted and we do not need to call fullReader.cancel(). diff --git a/test/unit/core_utils_spec.js b/test/unit/core_utils_spec.js index d3b78087e..24f2be1e9 100644 --- a/test/unit/core_utils_spec.js +++ b/test/unit/core_utils_spec.js @@ -218,10 +218,10 @@ describe("core_utils", function () { describe("isWhiteSpace", function () { it("handles space characters", function () { - expect(isWhiteSpace(0x20)).toEqual(true); - expect(isWhiteSpace(0x09)).toEqual(true); - expect(isWhiteSpace(0x0d)).toEqual(true); - expect(isWhiteSpace(0x0a)).toEqual(true); + expect(isWhiteSpace(0x20)).toBeTrue(); + expect(isWhiteSpace(0x09)).toBeTrue(); + expect(isWhiteSpace(0x0d)).toBeTrue(); + expect(isWhiteSpace(0x0a)).toBeTrue(); }); it("handles non-space characters", function () { @@ -336,13 +336,13 @@ describe("core_utils", function () { expect(validateCSSFont(cssFontInfo)).toBeFalse(); cssFontInfo.fontFamily = `"blah blah \\" blah blah"`; - expect(validateCSSFont(cssFontInfo)).toEqual(true); + expect(validateCSSFont(cssFontInfo)).toBeTrue(); cssFontInfo.fontFamily = `'blah blah ' blah blah'`; expect(validateCSSFont(cssFontInfo)).toBeFalse(); cssFontInfo.fontFamily = `'blah blah \\' blah blah'`; - expect(validateCSSFont(cssFontInfo)).toEqual(true); + expect(validateCSSFont(cssFontInfo)).toBeTrue(); cssFontInfo.fontFamily = `"blah blah `; expect(validateCSSFont(cssFontInfo)).toBeFalse(); @@ -357,7 +357,7 @@ describe("core_utils", function () { expect(validateCSSFont(cssFontInfo)).toBeFalse(); cssFontInfo.fontFamily = "blah blah blah"; - expect(validateCSSFont(cssFontInfo)).toEqual(true); + expect(validateCSSFont(cssFontInfo)).toBeTrue(); cssFontInfo.fontFamily = "blah 0blah blah"; expect(validateCSSFont(cssFontInfo)).toBeFalse(); @@ -369,10 +369,10 @@ describe("core_utils", function () { expect(validateCSSFont(cssFontInfo)).toBeFalse(); cssFontInfo.fontFamily = "blah blah -blah"; - expect(validateCSSFont(cssFontInfo)).toEqual(true); + expect(validateCSSFont(cssFontInfo)).toBeTrue(); cssFontInfo.fontFamily = "blah fdqAJqjHJK23kl23__--Kj blah"; - expect(validateCSSFont(cssFontInfo)).toEqual(true); + expect(validateCSSFont(cssFontInfo)).toBeTrue(); cssFontInfo.fontFamily = "blah fdqAJqjH$JK23kl23__--Kj blah"; expect(validateCSSFont(cssFontInfo)).toBeFalse(); diff --git a/test/unit/crypto_spec.js b/test/unit/crypto_spec.js index 044473710..f95363604 100644 --- a/test/unit/crypto_spec.js +++ b/test/unit/crypto_spec.js @@ -352,7 +352,7 @@ describe("crypto", function () { userValidation, userPassword ); - expect(result).toEqual(true); + expect(result).toBeTrue(); }); it("should correctly check an owner key", function () { @@ -378,7 +378,7 @@ describe("crypto", function () { uBytes, ownerPassword ); - expect(result).toEqual(true); + expect(result).toBeTrue(); }); it("should generate a file encryption key from the user key", function () { @@ -445,7 +445,7 @@ describe("crypto", function () { userValidation, userPassword ); - expect(result).toEqual(true); + expect(result).toBeTrue(); }); it("should correctly check an owner key", function () { @@ -470,7 +470,7 @@ describe("crypto", function () { uBytes, ownerPassword ); - expect(result).toEqual(true); + expect(result).toBeTrue(); }); it("should generate a file encryption key from the user key", function () { @@ -573,10 +573,10 @@ describe("CipherTransformFactory", function () { function ensurePasswordCorrect(dict, fileId, password) { try { const factory = new CipherTransformFactory(dict, fileId, password); - expect("createCipherTransform" in factory).toEqual(true); + expect("createCipherTransform" in factory).toBeTrue(); } catch { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } } @@ -586,7 +586,7 @@ describe("CipherTransformFactory", function () { new CipherTransformFactory(dict, fileId, password); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (ex) { expect(ex).toBeInstanceOf(PasswordException); expect(ex.code).toEqual(PasswordResponses.NEED_PASSWORD); @@ -599,7 +599,7 @@ describe("CipherTransformFactory", function () { new CipherTransformFactory(dict, fileId, password); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (ex) { expect(ex).toBeInstanceOf(PasswordException); expect(ex.code).toEqual(PasswordResponses.INCORRECT_PASSWORD); diff --git a/test/unit/custom_spec.js b/test/unit/custom_spec.js index 4c3d75918..63263c382 100644 --- a/test/unit/custom_spec.js +++ b/test/unit/custom_spec.js @@ -205,7 +205,7 @@ describe("custom ownerDocument", function () { await loadingTask.destroy(); canvasFactory.destroy(canvasAndCtx); - expect(style.remove.called).toBe(true); + expect(style.remove.called).toBeTrue(); }); it("should use a constructable stylesheet for CSS font rules", function () { diff --git a/test/unit/display_utils_spec.js b/test/unit/display_utils_spec.js index 3b7fe45eb..dca05bbab 100644 --- a/test/unit/display_utils_spec.js +++ b/test/unit/display_utils_spec.js @@ -181,7 +181,7 @@ describe("display_utils", function () { new Blob([typedArray], { type: "application/pdf" }) ); // Sanity check to ensure that a "blob:" URL was returned. - expect(blobUrl.startsWith("blob:")).toEqual(true); + expect(blobUrl.startsWith("blob:")).toBeTrue(); expect(getPdfFilenameFromUrl(blobUrl + "?file.pdf")).toEqual("file.pdf"); }); @@ -225,7 +225,7 @@ describe("display_utils", function () { it("handles relative Fetch URLs", function () { expect(isValidFetchUrl("/foo", "file://www.example.com")).toBeFalse(); - expect(isValidFetchUrl("/foo", "http://www.example.com")).toEqual(true); + expect(isValidFetchUrl("/foo", "http://www.example.com")).toBeTrue(); }); it("handles unsupported Fetch protocols", function () { @@ -234,8 +234,8 @@ describe("display_utils", function () { }); it("handles supported Fetch protocols", function () { - expect(isValidFetchUrl("http://www.example.com")).toEqual(true); - expect(isValidFetchUrl("https://www.example.com")).toEqual(true); + expect(isValidFetchUrl("http://www.example.com")).toBeTrue(); + expect(isValidFetchUrl("https://www.example.com")).toBeTrue(); }); }); diff --git a/test/unit/document_spec.js b/test/unit/document_spec.js index 295a03d63..93fc14967 100644 --- a/test/unit/document_spec.js +++ b/test/unit/document_spec.js @@ -650,7 +650,7 @@ describe("document", function () { pdfDocument = getDocument(acroForm, xref); hasJSActions = await pdfDocument.hasJSActions; - expect(hasJSActions).toEqual(true); + expect(hasJSActions).toBeTrue(); }); }); }); diff --git a/test/unit/encodings_spec.js b/test/unit/encodings_spec.js index 4abbeab04..96114145c 100644 --- a/test/unit/encodings_spec.js +++ b/test/unit/encodings_spec.js @@ -30,7 +30,7 @@ describe("encodings", function () { for (const knownEncodingName of knownEncodingNames) { const encoding = getEncoding(knownEncodingName); - expect(Array.isArray(encoding)).toEqual(true); + expect(Array.isArray(encoding)).toBeTrue(); expect(encoding.length).toEqual(256); for (const item of encoding) { diff --git a/test/unit/evaluator_spec.js b/test/unit/evaluator_spec.js index bfc51f47b..cb8b5ff15 100644 --- a/test/unit/evaluator_spec.js +++ b/test/unit/evaluator_spec.js @@ -74,7 +74,7 @@ describe("evaluator", function () { stream, new ResourcesMock() ); - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray.length).toEqual(1); expect(result.fnArray[0]).toEqual(OPS.constructPath); expect(result.argsArray[0]).toEqual([OPS.fill, [null], null]); @@ -87,7 +87,7 @@ describe("evaluator", function () { stream, new ResourcesMock() ); - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray.length).toEqual(1); expect(result.fnArray[0]).toEqual(OPS.restore); }); @@ -130,7 +130,7 @@ describe("evaluator", function () { stream, new ResourcesMock() ); - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray.length).toEqual(3); expect(result.fnArray).toEqual([ OPS.constructPath, @@ -151,7 +151,7 @@ describe("evaluator", function () { stream, resources ); - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray).toEqual([ OPS.constructPath, OPS.constructPath, @@ -169,7 +169,7 @@ describe("evaluator", function () { stream, new ResourcesMock() ); - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray.length).toEqual(2); expect(result.fnArray[0]).toEqual(OPS.constructPath); expect(result.fnArray[1]).toEqual(OPS.setTextRise); @@ -185,14 +185,14 @@ describe("evaluator", function () { stream, new ResourcesMock() ); - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray.length).toEqual(3); expect(result.fnArray[0]).toEqual(OPS.setFlatness); expect(result.fnArray[1]).toEqual(OPS.setRenderingIntent); expect(result.fnArray[2]).toEqual(OPS.constructPath); expect(result.argsArray.length).toEqual(3); expect(result.argsArray[0].length).toEqual(1); - expect(result.argsArray[0][0]).toEqual(true); + expect(result.argsArray[0][0]).toBeTrue(); expect(result.argsArray[1].length).toEqual(1); expect(result.argsArray[1][0]).toBeFalse(); expect(result.argsArray[2]).toEqual([OPS.endPath, [null], null]); @@ -296,7 +296,7 @@ describe("evaluator", function () { ); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(FormatError); expect(reason.message).toEqual( @@ -313,7 +313,7 @@ describe("evaluator", function () { stream, new ResourcesMock() ); - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray.length).toEqual(4); expect(result.fnArray[0]).toEqual(OPS.save); expect(result.fnArray[1]).toEqual(OPS.save); @@ -332,7 +332,7 @@ describe("evaluator", function () { ); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(reason).toBeInstanceOf(FormatError); expect(reason.message).toEqual("XObject should be a stream"); @@ -416,9 +416,9 @@ describe("evaluator", function () { }); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch { - expect(!!result.fnArray && !!result.argsArray).toEqual(true); + expect(!!result.fnArray && !!result.argsArray).toBeTrue(); expect(result.fnArray.length).toEqual(0); } }); @@ -437,9 +437,9 @@ describe("evaluator", function () { }); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch { - expect(true).toEqual(true); + expect(true).toBeTrue(); } }); }); diff --git a/test/unit/event_utils_spec.js b/test/unit/event_utils_spec.js index 5d971bfbb..05ae986aa 100644 --- a/test/unit/event_utils_spec.js +++ b/test/unit/event_utils_spec.js @@ -209,7 +209,7 @@ describe("event_utils", function () { }); function domEventListener() { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } document.addEventListener("test", domEventListener); @@ -240,7 +240,7 @@ describe("event_utils", function () { }).then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }, function (reason) { expect(reason).toBeInstanceOf(Error); @@ -253,7 +253,7 @@ describe("event_utils", function () { }).then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }, function (reason) { expect(reason).toBeInstanceOf(Error); @@ -267,7 +267,7 @@ describe("event_utils", function () { }).then( function () { // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); }, function (reason) { expect(reason).toBeInstanceOf(Error); diff --git a/test/unit/fetch_stream_spec.js b/test/unit/fetch_stream_spec.js index 04dab972e..718754aa4 100644 --- a/test/unit/fetch_stream_spec.js +++ b/test/unit/fetch_stream_spec.js @@ -63,7 +63,7 @@ describe("fetch_stream", function () { await read(); expect(len).toEqual(pdfLength); - expect(isStreamingSupported).toEqual(true); + expect(isStreamingSupported).toBeTrue(); expect(isRangeSupported).toBeFalse(); }); @@ -112,9 +112,9 @@ describe("fetch_stream", function () { read(rangeReader2, result2), ]); - expect(isStreamingSupported).toEqual(true); - expect(isRangeSupported).toEqual(true); - expect(fullReaderCancelled).toEqual(true); + expect(isStreamingSupported).toBeTrue(); + expect(isRangeSupported).toBeTrue(); + expect(fullReaderCancelled).toBeTrue(); expect(result1.value).toEqual(rangeSize); expect(result2.value).toEqual(tailSize); }); diff --git a/test/unit/message_handler_spec.js b/test/unit/message_handler_spec.js index 0dee0ae6b..e6f5db892 100644 --- a/test/unit/message_handler_spec.js +++ b/test/unit/message_handler_spec.js @@ -81,7 +81,7 @@ describe("message_handler", function () { await sleep(10); result = await reader.read(); expect(result.value).toBeUndefined(); - expect(result.done).toEqual(true); + expect(result.done).toBeTrue(); }); it("should not read any data when cancelled", async function () { @@ -191,7 +191,7 @@ describe("message_handler", function () { await reader.read(); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (reason) { expect(log).toEqual("01pe"); expect(reason).toBeInstanceOf(UnknownErrorException); @@ -261,7 +261,7 @@ describe("message_handler", function () { result = await reader.read(); expect(result.value).toBeUndefined(); - expect(result.done).toEqual(true); + expect(result.done).toBeTrue(); }); it( @@ -328,7 +328,7 @@ describe("message_handler", function () { result = await reader.read(); expect(result.value).toBeUndefined(); - expect(result.done).toEqual(true); + expect(result.done).toBeTrue(); } ); @@ -382,7 +382,7 @@ describe("message_handler", function () { result = await reader.read(); expect(result.value).toBeUndefined(); - expect(result.done).toEqual(true); + expect(result.done).toBeTrue(); }); }); }); diff --git a/test/unit/network_spec.js b/test/unit/network_spec.js index 1995ebbc6..904e67474 100644 --- a/test/unit/network_spec.js +++ b/test/unit/network_spec.js @@ -114,8 +114,8 @@ describe("network", function () { expect(result1.value).toEqual(rangeSize); expect(result2.value).toEqual(tailSize); expect(isStreamingSupported).toBeFalse(); - expect(isRangeSupported).toEqual(true); - expect(fullReaderCancelled).toEqual(true); + expect(isRangeSupported).toBeTrue(); + expect(fullReaderCancelled).toBeTrue(); }); it(`handle reading ranges with missing/invalid "Content-Range" header`, async function () { @@ -140,7 +140,7 @@ describe("network", function () { await fullReader.headersReady; // Ensure that range requests are supported. - expect(fullReader.isRangeSupported).toEqual(true); + expect(fullReader.isRangeSupported).toBeTrue(); // We shall be able to close the full reader without issues. fullReader.cancel(new AbortException("Don't need fullReader.")); @@ -153,7 +153,7 @@ describe("network", function () { await rangeReader.read(); // Shouldn't get here. - expect(false).toEqual(true); + expect(false).toBeTrue(); } catch (ex) { expect(ex).toBeInstanceOf(ResponseException); expect(ex.status).toEqual(0); diff --git a/test/unit/node_stream_spec.js b/test/unit/node_stream_spec.js index a765033c5..66621563f 100644 --- a/test/unit/node_stream_spec.js +++ b/test/unit/node_stream_spec.js @@ -114,8 +114,8 @@ describe("node_stream", function () { expect(result1.value).toEqual(rangeSize); expect(result2.value).toEqual(tailSize); expect(isStreamingSupported).toBeFalse(); - expect(isRangeSupported).toEqual(true); - expect(fullReaderCancelled).toEqual(true); + expect(isRangeSupported).toBeTrue(); + expect(fullReaderCancelled).toBeTrue(); }); it("read filesystem pdf files (smaller than two range requests)", async function () { diff --git a/test/unit/obj_bin_transform_spec.js b/test/unit/obj_bin_transform_spec.js index 9747140dd..a96c08c8e 100644 --- a/test/unit/obj_bin_transform_spec.js +++ b/test/unit/obj_bin_transform_spec.js @@ -134,16 +134,16 @@ describe("obj_bin_transform", function () { const buffer = compileFontInfo(fontInfo); expect(buffer.byteLength).toEqual(sizeEstimate); const deserialized = new FontInfo({ buffer }); - expect(deserialized.black).toEqual(true); - expect(deserialized.bold).toEqual(true); - expect(deserialized.disableFontFace).toEqual(true); - expect(deserialized.fontExtraProperties).toEqual(true); - expect(deserialized.isInvalidPDFjsFont).toEqual(true); - expect(deserialized.isType3Font).toEqual(true); - expect(deserialized.italic).toEqual(true); - expect(deserialized.missingFile).toEqual(true); - expect(deserialized.remeasure).toEqual(true); - expect(deserialized.vertical).toEqual(true); + expect(deserialized.black).toBeTrue(); + expect(deserialized.bold).toBeTrue(); + expect(deserialized.disableFontFace).toBeTrue(); + expect(deserialized.fontExtraProperties).toBeTrue(); + expect(deserialized.isInvalidPDFjsFont).toBeTrue(); + expect(deserialized.isType3Font).toBeTrue(); + expect(deserialized.italic).toBeTrue(); + expect(deserialized.missingFile).toBeTrue(); + expect(deserialized.remeasure).toBeTrue(); + expect(deserialized.vertical).toBeTrue(); expect(deserialized.ascent).toEqual(1); expect(deserialized.defaultWidth).toEqual(1); expect(deserialized.descent).toEqual(1); diff --git a/test/unit/parser_spec.js b/test/unit/parser_spec.js index a2091fdb8..12015ec19 100644 --- a/test/unit/parser_spec.js +++ b/test/unit/parser_spec.js @@ -120,7 +120,7 @@ describe("parser", function () { "work-around rounding bugs in Chromium browsers." ); - expect(true).toEqual(true); + expect(true).toBeTrue(); continue; } expect(result).toEqual(expected); diff --git a/test/unit/pdf_find_utils_spec.js b/test/unit/pdf_find_utils_spec.js index 6d3d832e7..754baaeaa 100644 --- a/test/unit/pdf_find_utils_spec.js +++ b/test/unit/pdf_find_utils_spec.js @@ -36,10 +36,10 @@ describe("pdf_find_utils", function () { it("treats ASCII punctuation as a word boundary", function () { const content = "foo-bar (baz)"; - expect(isEntireWord(content, 0, 3)).toEqual(true); // "foo" before "-" - expect(isEntireWord(content, 4, 3)).toEqual(true); // "bar" before " " - expect(isEntireWord(content, 9, 3)).toEqual(true); // "baz" inside "()" - expect(isEntireWord(content, 0, 7)).toEqual(true); // "foo-bar" + expect(isEntireWord(content, 0, 3)).toBeTrue(); // "foo" before "-" + expect(isEntireWord(content, 4, 3)).toBeTrue(); // "bar" before " " + expect(isEntireWord(content, 9, 3)).toBeTrue(); // "baz" inside "()" + expect(isEntireWord(content, 0, 7)).toBeTrue(); // "foo-bar" }); it("treats non-ASCII punctuation as a word boundary", function () { @@ -51,7 +51,7 @@ describe("pdf_find_utils", function () { ["—", "—"], // em dashes ]) { const content = `${open}word${close}`; - expect(isEntireWord(content, 1, 4)).toEqual(true); // "word" + expect(isEntireWord(content, 1, 4)).toBeTrue(); // "word" expect(isEntireWord(content, 1, 3)).toBeFalse(); // "wor" } }); @@ -61,16 +61,16 @@ describe("pdf_find_utils", function () { // preceding word from matching as an entire word. for (const superscript of ["¹", "²", "³", "⁴"]) { const content = `word${superscript}`; - expect(isEntireWord(content, 0, 4)).toEqual(true); // "word" + expect(isEntireWord(content, 0, 4)).toBeTrue(); // "word" } }); it("matches a word next to a contraction apostrophe", function () { // The apostrophe is a word break in isolation (as in Firefox's find), so // the leading part of a contraction is still an entire word. - expect(isEntireWord("I can't do that", 2, 3)).toEqual(true); // "can" - expect(isEntireWord("don't", 0, 3)).toEqual(true); // "don" - expect(isEntireWord("it's", 0, 2)).toEqual(true); // "it" + expect(isEntireWord("I can't do that", 2, 3)).toBeTrue(); // "can" + expect(isEntireWord("don't", 0, 3)).toBeTrue(); // "don" + expect(isEntireWord("it's", 0, 2)).toBeTrue(); // "it" }); it("keeps a word joined by a connecting character", function () { @@ -82,7 +82,7 @@ describe("pdf_find_utils", function () { // "café" in the normalized page content is NFD: "cafe" followed by // U+0301 COMBINING ACUTE ACCENT. const content = "café".normalize("NFD"); - expect(isEntireWord(content, 0, content.length)).toEqual(true); // whole + expect(isEntireWord(content, 0, content.length)).toBeTrue(); // whole expect(isEntireWord(content, 0, 3)).toBeFalse(); // "caf" expect(isEntireWord(content, 0, 4)).toBeFalse(); // "cafe", before U+0301 }); @@ -93,7 +93,7 @@ describe("pdf_find_utils", function () { expect(isEntireWord(ab, 2, 1)).toBeFalse(); // "b" inside "áb" expect(isEntireWord(ab, 0, 2)).toBeFalse(); // "á" inside "áb" // "café" is a whole word before a space, but not inside "caféteria". - expect(isEntireWord("café bar".normalize("NFD"), 0, 5)).toEqual(true); + expect(isEntireWord("café bar".normalize("NFD"), 0, 5)).toBeTrue(); expect(isEntireWord("caféteria".normalize("NFD"), 0, 5)).toBeFalse(); }); @@ -103,7 +103,7 @@ describe("pdf_find_utils", function () { expect(isEntireWord(withBoldA, 0, 1)).toBeFalse(); // "a" expect(isEntireWord(withBoldA, 3, 1)).toBeFalse(); // "b" // Each CJK ideograph is its own word (𠀀 = U+20000, a surrogate pair). - expect(isEntireWord("中\u{20000}国", 0, 1)).toEqual(true); // "中" + expect(isEntireWord("中\u{20000}国", 0, 1)).toBeTrue(); // "中" }); }); }); diff --git a/test/unit/pdf_history_spec.js b/test/unit/pdf_history_spec.js index 47676f985..dc0a5340c 100644 --- a/test/unit/pdf_history_spec.js +++ b/test/unit/pdf_history_spec.js @@ -41,12 +41,12 @@ describe("pdf_history", function () { }); it("should accept equal destination hashes", function () { - expect(isDestHashesEqual("page.157", "page.157")).toEqual(true); - expect(isDestHashesEqual("nameddest=page.157", "page.157")).toEqual(true); + expect(isDestHashesEqual("page.157", "page.157")).toBeTrue(); + expect(isDestHashesEqual("nameddest=page.157", "page.157")).toBeTrue(); expect( isDestHashesEqual("nameddest=page.157&zoom=100", "page.157") - ).toEqual(true); + ).toBeTrue(); }); }); @@ -67,13 +67,13 @@ describe("pdf_history", function () { }); it("should accept equal destination arrays", function () { - expect(isDestArraysEqual(firstDest, firstDest)).toEqual(true); - expect(isDestArraysEqual(firstDest, fifthDest)).toEqual(true); + expect(isDestArraysEqual(firstDest, firstDest)).toBeTrue(); + expect(isDestArraysEqual(firstDest, fifthDest)).toBeTrue(); const firstDestCopy = firstDest.slice(); expect(firstDest).not.toBe(firstDestCopy); - expect(isDestArraysEqual(firstDest, firstDestCopy)).toEqual(true); + expect(isDestArraysEqual(firstDest, firstDestCopy)).toBeTrue(); }); }); }); diff --git a/test/unit/pdf_viewer_spec.js b/test/unit/pdf_viewer_spec.js index a89be6460..4ca1e6823 100644 --- a/test/unit/pdf_viewer_spec.js +++ b/test/unit/pdf_viewer_spec.js @@ -155,7 +155,7 @@ describe("PDFViewer", function () { const view = iterator.next().value; buffer.push(view); } - expect(buffer.has(viewsMap.get(1))).toEqual(true); + expect(buffer.has(viewsMap.get(1))).toBeTrue(); expect(buffer.has(viewsMap.get(2))).toBeFalse(); }); }); diff --git a/test/unit/postscript_spec.js b/test/unit/postscript_spec.js index 5e0939b6f..1e4e131ba 100644 --- a/test/unit/postscript_spec.js +++ b/test/unit/postscript_spec.js @@ -1189,7 +1189,7 @@ describe("PostScript Type 4 lexer, parser, and Wasm compiler", function () { it("true and false become PsConstNode", function () { const out = toTree("{ true false }", 0); expect(out[0]).toBeInstanceOf(PsConstNode); - expect(out[0].value).toBe(true); + expect(out[0].value).toBeTrue(); expect(out[1]).toBeInstanceOf(PsConstNode); expect(out[1].value).toBeFalse(); }); @@ -1427,7 +1427,7 @@ describe("PostScript Type 4 lexer, parser, and Wasm compiler", function () { it("x or true → true", function () { const out = toTree("{ true or }", 1); expect(out[0]).toBeInstanceOf(PsConstNode); - expect(out[0].value).toBe(true); + expect(out[0].value).toBeTrue(); }); // not(comparison) → negated comparison @@ -1508,7 +1508,7 @@ describe("PostScript Type 4 lexer, parser, and Wasm compiler", function () { it("x eq x → true (reflexive eq)", function () { const out = toTree("{ dup eq }", 1); expect(out[0]).toBeInstanceOf(PsConstNode); - expect(out[0].value).toBe(true); + expect(out[0].value).toBeTrue(); }); it("x and x → x (reflexive and)", function () { @@ -1626,7 +1626,7 @@ describe("PostScript Type 4 lexer, parser, and Wasm compiler", function () { it("true or x → true (second=true or)", function () { const out = toTree("{ true exch or }", 1); expect(out[0]).toBeInstanceOf(PsConstNode); - expect(out[0].value).toBe(true); + expect(out[0].value).toBeTrue(); }); it("no simplification when second operand is a non-special constant", function () { @@ -1812,18 +1812,18 @@ describe("PostScript Type 4 lexer, parser, and Wasm compiler", function () { }); it("constant-folds comparison operators", function () { - expect(toTree("{ 1 1 eq }", 0)[0].value).toBe(true); - expect(toTree("{ 1 2 ne }", 0)[0].value).toBe(true); - expect(toTree("{ 2 1 gt }", 0)[0].value).toBe(true); // a=2 > b=1 - expect(toTree("{ 1 1 ge }", 0)[0].value).toBe(true); - expect(toTree("{ 1 2 lt }", 0)[0].value).toBe(true); // a=1 < b=2 - expect(toTree("{ 1 2 le }", 0)[0].value).toBe(true); + expect(toTree("{ 1 1 eq }", 0)[0].value).toBeTrue(); + expect(toTree("{ 1 2 ne }", 0)[0].value).toBeTrue(); + expect(toTree("{ 2 1 gt }", 0)[0].value).toBeTrue(); // a=2 > b=1 + expect(toTree("{ 1 1 ge }", 0)[0].value).toBeTrue(); + expect(toTree("{ 1 2 lt }", 0)[0].value).toBeTrue(); // a=1 < b=2 + expect(toTree("{ 1 2 le }", 0)[0].value).toBeTrue(); }); it("constant-folds boolean and, or, xor and bitshift", function () { expect(toTree("{ true false and }", 0)[0].value).toBeFalse(); - expect(toTree("{ false true or }", 0)[0].value).toBe(true); - expect(toTree("{ true false xor }", 0)[0].value).toBe(true); + expect(toTree("{ false true or }", 0)[0].value).toBeTrue(); + expect(toTree("{ true false xor }", 0)[0].value).toBeTrue(); expect(toTree("{ 4 2 bitshift }", 0)[0].value).toBe(16); // 4 << 2 }); diff --git a/test/unit/primitives_spec.js b/test/unit/primitives_spec.js index b4586f972..c2b7fa53a 100644 --- a/test/unit/primitives_spec.js +++ b/test/unit/primitives_spec.js @@ -586,20 +586,20 @@ describe("primitives", function () { it("handles names", function () { const name = Name.get("Font"); - expect(isName(name)).toEqual(true); + expect(isName(name)).toBeTrue(); }); it("handles names with name check", function () { const name = Name.get("Font"); - expect(isName(name, "Font")).toEqual(true); + expect(isName(name, "Font")).toBeTrue(); expect(isName(name, "Subtype")).toBeFalse(); }); it("handles *empty* names, with name check", function () { const emptyName = Name.get(""); - expect(isName(emptyName)).toEqual(true); - expect(isName(emptyName, "")).toEqual(true); + expect(isName(emptyName)).toBeTrue(); + expect(isName(emptyName, "")).toBeTrue(); expect(isName(emptyName, "string")).toBeFalse(); }); @@ -616,12 +616,12 @@ describe("primitives", function () { it("handles commands", function () { const cmd = Cmd.get("BT"); - expect(isCmd(cmd)).toEqual(true); + expect(isCmd(cmd)).toBeTrue(); }); it("handles commands with cmd check", function () { const cmd = Cmd.get("BT"); - expect(isCmd(cmd, "BT")).toEqual(true); + expect(isCmd(cmd, "BT")).toBeTrue(); expect(isCmd(cmd, "ET")).toBeFalse(); }); @@ -638,14 +638,14 @@ describe("primitives", function () { it("handles empty dictionaries with type check", function () { const dict = Dict.empty; - expect(isDict(dict)).toEqual(true); + expect(isDict(dict)).toBeTrue(); expect(isDict(dict, "Page")).toBeFalse(); }); it("handles dictionaries with type check", function () { const dict = new Dict(); dict.set("Type", Name.get("Page")); - expect(isDict(dict, "Page")).toEqual(true); + expect(isDict(dict, "Page")).toBeTrue(); expect(isDict(dict, "Contents")).toBeFalse(); }); @@ -656,7 +656,7 @@ describe("primitives", function () { it("should handle Refs pointing to the same object", function () { const ref1 = Ref.get(1, 0); const ref2 = Ref.get(1, 0); - expect(isRefsEqual(ref1, ref2)).toEqual(true); + expect(isRefsEqual(ref1, ref2)).toBeTrue(); }); it("should handle Refs pointing to different objects", function () { diff --git a/test/unit/scripting_spec.js b/test/unit/scripting_spec.js index e31107179..3e7b133ce 100644 --- a/test/unit/scripting_spec.js +++ b/test/unit/scripting_spec.js @@ -117,7 +117,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -356,7 +356,7 @@ describe("Scripting", function () { willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "123", @@ -392,7 +392,7 @@ describe("Scripting", function () { selEnd: 4, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -430,7 +430,7 @@ describe("Scripting", function () { selEnd: 4, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -504,7 +504,7 @@ describe("Scripting", function () { willCommit: true, }); - expect(send_queue.has(refId1)).toEqual(true); + expect(send_queue.has(refId1)).toBeTrue(); expect(send_queue.get(refId1)).toEqual({ id: refId1, siblings: null, @@ -646,7 +646,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has("alert")).toEqual(true); + expect(send_queue.has("alert")).toBeTrue(); expect(send_queue.get("alert")).toEqual({ command: "alert", value: "hello", @@ -801,7 +801,7 @@ describe("Scripting", function () { value: "0", name: "test1", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "0.00€", @@ -813,7 +813,7 @@ describe("Scripting", function () { value: "", name: "test6", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "0.00€", @@ -825,7 +825,7 @@ describe("Scripting", function () { value: "123456.789", name: "test1", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "123,456.79€", @@ -837,7 +837,7 @@ describe("Scripting", function () { value: "223456.789", name: "test2", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "$223456,8", @@ -849,7 +849,7 @@ describe("Scripting", function () { value: "-323456.789", name: "test3", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "323,456.79€", @@ -862,7 +862,7 @@ describe("Scripting", function () { value: "-423456.789", name: "test4", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "(423,456.79€)", @@ -874,7 +874,7 @@ describe("Scripting", function () { value: "-52345.678", name: "test5", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "(52,345.68€)", @@ -914,7 +914,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -953,7 +953,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has("alert")).toEqual(true); + expect(send_queue.has("alert")).toBeTrue(); expect(send_queue.get("alert")).toEqual({ command: "alert", value: @@ -996,7 +996,7 @@ describe("Scripting", function () { value: "0.456789", name: "test1", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "45.68%", @@ -1008,7 +1008,7 @@ describe("Scripting", function () { value: "0.456789", name: "test2", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "%45.68", @@ -1046,7 +1046,7 @@ describe("Scripting", function () { value: "Sun Apr 15 2007 03:14:15", name: "test1", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "4/15", @@ -1058,7 +1058,7 @@ describe("Scripting", function () { value: "Sun Apr 15 2007 03:14:15", name: "test2", }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, value: "4/15/07 3:14 am", @@ -1093,7 +1093,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1108,7 +1108,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1124,7 +1124,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1140,7 +1140,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1179,7 +1179,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1215,7 +1215,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has("alert")).toEqual(true); + expect(send_queue.has("alert")).toBeTrue(); expect(send_queue.get("alert")).toEqual({ command: "alert", value: @@ -1290,7 +1290,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[3])).toEqual(true); + expect(send_queue.has(refIds[3])).toBeTrue(); expect(send_queue.get(refIds[3])).toEqual({ id: refIds[3], siblings: null, @@ -1304,7 +1304,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[3])).toEqual(true); + expect(send_queue.has(refIds[3])).toBeTrue(); expect(send_queue.get(refIds[3])).toEqual({ id: refIds[3], siblings: null, @@ -1318,7 +1318,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[3])).toEqual(true); + expect(send_queue.has(refIds[3])).toBeTrue(); expect(send_queue.get(refIds[3])).toEqual({ id: refIds[3], siblings: null, @@ -1326,7 +1326,7 @@ describe("Scripting", function () { formattedValue: null, }); - expect(send_queue.has(refIds[4])).toEqual(true); + expect(send_queue.has(refIds[4])).toBeTrue(); expect(send_queue.get(refIds[4])).toEqual({ id: refIds[4], siblings: null, @@ -1396,7 +1396,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[5])).toEqual(true); + expect(send_queue.has(refIds[5])).toBeTrue(); expect(send_queue.get(refIds[5])).toEqual({ id: refIds[5], siblings: null, @@ -1410,7 +1410,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[5])).toEqual(true); + expect(send_queue.has(refIds[5])).toBeTrue(); expect(send_queue.get(refIds[5])).toEqual({ id: refIds[5], siblings: null, @@ -1484,7 +1484,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[3])).toEqual(true); + expect(send_queue.has(refIds[3])).toBeTrue(); expect(send_queue.get(refIds[3])).toEqual({ id: refIds[3], siblings: null, @@ -1498,7 +1498,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[3])).toEqual(true); + expect(send_queue.has(refIds[3])).toBeTrue(); expect(send_queue.get(refIds[3])).toEqual({ id: refIds[3], siblings: null, @@ -1512,7 +1512,7 @@ describe("Scripting", function () { name: "Keystroke", willCommit: true, }); - expect(send_queue.has(refIds[3])).toEqual(true); + expect(send_queue.has(refIds[3])).toBeTrue(); expect(send_queue.get(refIds[3])).toEqual({ id: refIds[3], siblings: null, @@ -1520,7 +1520,7 @@ describe("Scripting", function () { formattedValue: null, }); - expect(send_queue.has(refIds[4])).toEqual(true); + expect(send_queue.has(refIds[4])).toBeTrue(); expect(send_queue.get(refIds[4])).toEqual({ id: refIds[4], siblings: null, @@ -1560,7 +1560,7 @@ describe("Scripting", function () { selStart: 0, selEnd: 0, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); await sandbox.dispatchEventInSandbox({ @@ -1572,7 +1572,7 @@ describe("Scripting", function () { selStart: 1, selEnd: 1, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); await sandbox.dispatchEventInSandbox({ @@ -1584,7 +1584,7 @@ describe("Scripting", function () { selStart: 2, selEnd: 2, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); await sandbox.dispatchEventInSandbox({ @@ -1596,7 +1596,7 @@ describe("Scripting", function () { selStart: 3, selEnd: 3, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1614,7 +1614,7 @@ describe("Scripting", function () { selStart: 3, selEnd: 3, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); await sandbox.dispatchEventInSandbox({ @@ -1625,7 +1625,7 @@ describe("Scripting", function () { selStart: 4, selEnd: 4, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1672,7 +1672,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); value += change; } @@ -1686,7 +1686,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1733,7 +1733,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); value += change; } @@ -1747,7 +1747,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1794,7 +1794,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); value += change; } @@ -1808,7 +1808,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1855,7 +1855,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); value += change; } @@ -1869,7 +1869,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1916,7 +1916,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); value += change; } @@ -1930,7 +1930,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -1977,7 +1977,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); send_queue.delete(refId); value += change; } @@ -1991,7 +1991,7 @@ describe("Scripting", function () { selStart: i, selEnd: i, }); - expect(send_queue.has(refId)).toEqual(true); + expect(send_queue.has(refId)).toBeTrue(); expect(send_queue.get(refId)).toEqual({ id: refId, siblings: null, @@ -2009,7 +2009,7 @@ describe("Scripting", function () { expect(value).toBeFalse(); value = await myeval(`eMailValidate("foo@bar.com")`); - expect(value).toEqual(true); + expect(value).toBeTrue(); value = await myeval(`eMailValidate("foo bar")`); expect(value).toBeFalse(); @@ -2019,7 +2019,7 @@ describe("Scripting", function () { describe("AFExactMatch", function () { it("should check matching between regexs and a string", async () => { let value = await myeval(`AFExactMatch(/\\d+/, "123")`); - expect(value).toEqual(true); + expect(value).toBeTrue(); value = await myeval(`AFExactMatch(/\\d+/, "foo")`); expect(value).toEqual(0); diff --git a/test/unit/string_utils_spec.js b/test/unit/string_utils_spec.js index ec831dafd..f85091ab5 100644 --- a/test/unit/string_utils_spec.js +++ b/test/unit/string_utils_spec.js @@ -23,12 +23,12 @@ import { describe("string_utils", function () { describe("isAscii", function () { it("handles ascii/non-ascii strings", function () { - expect(isAscii("hello world")).toEqual(true); + expect(isAscii("hello world")).toBeTrue(); expect(isAscii("こんにちは世界の")).toBeFalse(); expect(isAscii("hello world in Japanese is こんにちは世界の")).toEqual( false ); - expect(isAscii("")).toEqual(true); + expect(isAscii("")).toBeTrue(); expect(isAscii(123)).toBeFalse(); expect(isAscii(null)).toBeFalse(); expect(isAscii(undefined)).toBeFalse(); diff --git a/test/unit/ui_utils_spec.js b/test/unit/ui_utils_spec.js index 01b9c2f0b..afb874762 100644 --- a/test/unit/ui_utils_spec.js +++ b/test/unit/ui_utils_spec.js @@ -75,10 +75,10 @@ describe("ui_utils", function () { }); it("should accept valid angles", function () { - expect(isValidRotation(0)).toEqual(true); - expect(isValidRotation(90)).toEqual(true); - expect(isValidRotation(-270)).toEqual(true); - expect(isValidRotation(540)).toEqual(true); + expect(isValidRotation(0)).toBeTrue(); + expect(isValidRotation(90)).toBeTrue(); + expect(isValidRotation(-270)).toBeTrue(); + expect(isValidRotation(540)).toBeTrue(); }); }); @@ -89,14 +89,14 @@ describe("ui_utils", function () { width: 200, height: 400, }) - ).toEqual(true); + ).toBeTrue(); expect( isPortraitOrientation({ width: 500, height: 500, }) - ).toEqual(true); + ).toBeTrue(); }); it("should be landscape orientation", function () { diff --git a/test/unit/xfa_formcalc_spec.js b/test/unit/xfa_formcalc_spec.js index 3008a7623..0bb69371d 100644 --- a/test/unit/xfa_formcalc_spec.js +++ b/test/unit/xfa_formcalc_spec.js @@ -247,7 +247,7 @@ describe("FormCalc expression parser", function () { operand: { id: "こんにちは世界" }, index: -0, }); - expect(Object.is(-0, dump.index)).toBe(true); + expect(Object.is(-0, dump.index)).toBeTrue(); parser = new Parser(`こんにちは世界[+0]`); dump = parser.parse().dump()[0]; @@ -255,7 +255,7 @@ describe("FormCalc expression parser", function () { operand: { id: "こんにちは世界" }, index: +0, }); - expect(Object.is(+0, dump.index)).toBe(true); + expect(Object.is(+0, dump.index)).toBeTrue(); parser = new Parser(`こんにちは世界[*]`); expect(parser.parse().dump()[0]).toEqual({ @@ -267,7 +267,7 @@ describe("FormCalc expression parser", function () { it("should parse basic expression with dots", function () { const parser = new Parser("a.b.c.#d..e.f..g.*"); const exprlist = parser.parse(); - expect(exprlist.expressions[0].isDotExpression()).toEqual(true); + expect(exprlist.expressions[0].isDotExpression()).toBeTrue(); expect(exprlist.dump()[0]).toEqual({ operator: ".", left: { id: "a" }, @@ -733,8 +733,8 @@ endfunc it("should parse som predicate", () => { const parser = new Parser("a.b <= 3"); const expr = parser.parse().expressions[0]; - expect(expr.isSomPredicate()).toEqual(true); - expect(expr.left.isSomPredicate()).toEqual(true); + expect(expr.isSomPredicate()).toBeTrue(); + expect(expr.left.isSomPredicate()).toBeTrue(); }); }); }); diff --git a/test/unit/xfa_tohtml_spec.js b/test/unit/xfa_tohtml_spec.js index 2c7736d83..046c272f1 100644 --- a/test/unit/xfa_tohtml_spec.js +++ b/test/unit/xfa_tohtml_spec.js @@ -642,7 +642,7 @@ describe("XFAFactory", function () { const pages = await factory.getPages(); let a = searchHtmlNode(pages, "name", "a"); expect(a.attributes.href).toEqual("https://github.com/mozilla/pdf.js"); - expect(a.attributes.newWindow).toEqual(true); + expect(a.attributes.newWindow).toBeTrue(); a = searchHtmlNode(pages, "name", "a", false, [1]); expect(a.attributes.href).toEqual("https://github.com/allizom/pdf.js");