Repository: mozilla/pdf.js
File: test/unit/api_spec.js (JavaScript)

Code before:
        { num: 17, gen: 0 },
        { name: "XYZ" },
        69,
        125,
        0,
      ]);

      await loadingTask.destroy();
    });

    it("gets a destination, from /Names (NameTree) dictionary with keys using PDFDocEncoding (issue 14847)", async function () {
      const loadingTask = getDocument(buildGetDocumentParams("issue14847.pdf"));
      const pdfDoc = await loadingTask.promise;
      const destination = await pdfDoc.getDestination("index");
      expect(destination).toEqual([
        { num: 10, gen: 0 },
        { name: "XYZ" },
        85.039,
        728.504,
        null,
      ]);

      await loadingTask.destroy();
    });

    it("gets a destination, from /Names (NameTree) respectively /Dests dictionary", async function () {
      const loadingTask = getDocument(buildGetDocumentParams("issue19474.pdf"));
      const pdfDoc = await loadingTask.promise;
      const destination = await pdfDoc.getDestination("A");
      expect(destination).toEqual([{ num: 1, gen: 0 }, { name: "Fit" }]);

      await loadingTask.destroy();
    });

    it("gets non-string destination", async function () {
      let numberPromise = pdfDocument.getDestination(4.3);
      let booleanPromise = pdfDocument.getDestination(true);
      let arrayPromise = pdfDocument.getDestination([
        { num: 17, gen: 0 },
        { name: "XYZ" },
        0,
        841.89,
        null,
      ]);

      numberPromise = numberPromise.then(
        function () {
          throw new Error("shall fail for non-string destination.");
        },
        function (reason) {
          expect(reason instanceof Error).toEqual(true);

Review comment (suggestion):
This test "only" accesses a sinlge destination in the /Dests entry of the root dictionary.

I would suggets to add another test, that access another destination which is resolved through the /Dests name tree of the /Names dictionary ("B") for completion.

Code after:
        { num: 17, gen: 0 },
        { name: "XYZ" },
        69,
        125,
        0,
      ]);

      await loadingTask.destroy();
    });

    it("gets a destination, from /Names (NameTree) dictionary with keys using PDFDocEncoding (issue 14847)", async function () {
      const loadingTask = getDocument(buildGetDocumentParams("issue14847.pdf"));
      const pdfDoc = await loadingTask.promise;
      const destination = await pdfDoc.getDestination("index");
      expect(destination).toEqual([
        { num: 10, gen: 0 },
        { name: "XYZ" },
        85.039,
        728.504,
        null,
      ]);

      await loadingTask.destroy();
    });

    it("gets a destination, from /Names (NameTree) respectively /Dests dictionary", async function () {
      const loadingTask = getDocument(buildGetDocumentParams("issue19474.pdf"));
      const pdfDoc = await loadingTask.promise;

      const destA = await pdfDoc.getDestination("A");
      expect(destA).toEqual([{ num: 1, gen: 0 }, { name: "Fit" }]);

      const destB = await pdfDoc.getDestination("B");
      expect(destB).toEqual([{ num: 4, gen: 0 }, { name: "Fit" }]);

      const destC = await pdfDoc.getDestination("C");
      expect(destC).toEqual([{ num: 5, gen: 0 }, { name: "Fit" }]);

      await loadingTask.destroy();
    });

    it("gets non-string destination", async function () {
      let numberPromise = pdfDocument.getDestination(4.3);
      let booleanPromise = pdfDocument.getDestination(true);
      let arrayPromise = pdfDocument.getDestination([
        { num: 17, gen: 0 },
        { name: "XYZ" },
        0,
        841.89,
        null,
      ]);