Repository: mozilla/pdf.js
File: test/integration/ink_editor_spec.mjs (JavaScript)

Code before:
    );
    return d;
  };

  it("must retain correct curvature regardless of the page or the curve's endpoint location", async () => {
    await Promise.all(
      pages.map(async ([browserName, page]) => {
        await switchToInk(page);

        // Creating a reference curve on the first page with end
        // within the page boundaries.
        const d1 = await getCurveOnPage({ pageNumber: 1, page });

        // Creating a curve on the second page with end
        // beyond the page boundaries.
        const d2 = await getCurveOnPage({ pageNumber: 2, page });

        // Expect that the endpoint beyond the boundaries is ignored,
        // ensuring both curves have the same shape on both pages.
        expect(d1).withContext(`In ${browserName}`).toEqual(d2);
      })
    );
  });
});

describe("Should switch from an editor and mode to others in double clicking", () => {
  let pages;

  beforeEach(async () => {
    pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
  });

  afterEach(async () => {
    await closePages(pages);
  });

  it("must check that the editor an the mode are correct", async () => {
    await Promise.all(
      pages.map(async ([browserName, page]) => {
        await switchToInk(page);

        const editorLayerRect = await getRect(page, ".annotationEditorLayer");
        const drawStartX = editorLayerRect.x + 100;
        const drawStartY = editorLayerRect.y + 100;

        const inkSelector = getEditorSelector(0);
        const clickHandle = await waitForPointerUp(page);
        await page.mouse.move(drawStartX, drawStartY);
        await page.mouse.down();
        await page.mouse.move(drawStartX + 50, drawStartY + 50);
        await page.mouse.up();

Review comment (suggestion):
Nit:
```suggestion
describe("Should switch from an editor and mode to others by double clicking", () => {
```

Code after:
    );
    return d;
  };

  it("must retain correct curvature regardless of the page or the curve's endpoint location", async () => {
    await Promise.all(
      pages.map(async ([browserName, page]) => {
        await switchToInk(page);

        // Creating a reference curve on the first page with end
        // within the page boundaries.
        const d1 = await getCurveOnPage({ pageNumber: 1, page });

        // Creating a curve on the second page with end
        // beyond the page boundaries.
        const d2 = await getCurveOnPage({ pageNumber: 2, page });

        // Expect that the endpoint beyond the boundaries is ignored,
        // ensuring both curves have the same shape on both pages.
        expect(d1).withContext(`In ${browserName}`).toEqual(d2);
      })
    );
  });
});

describe("Should switch from an editor and mode to others by double clicking", () => {
  let pages;

  beforeEach(async () => {
    pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
  });

  afterEach(async () => {
    await closePages(pages);
  });

  it("must check that the editor an the mode are correct", async () => {
    await Promise.all(
      pages.map(async ([browserName, page]) => {
        await switchToInk(page);

        const editorLayerRect = await getRect(page, ".annotationEditorLayer");
        const drawStartX = editorLayerRect.x + 100;
        const drawStartY = editorLayerRect.y + 100;

        const inkSelector = getEditorSelector(0);
        const clickHandle = await waitForPointerUp(page);
        await page.mouse.move(drawStartX, drawStartY);
        await page.mouse.down();
        await page.mouse.move(drawStartX + 50, drawStartY + 50);
        await page.mouse.up();