Commit 1856c8ef authored by r-4bb1t's avatar r-4bb1t
Browse files

test: add test for direct object fetch cancellation in lookupObject

parent 886084a0
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -179,7 +179,38 @@ test("lookupObject()", {
    assertEquals(result, null);
  });

  fetchMock.removeRoutes();
  fetchMock.get(
    "https://example.com/slow-object",
    () =>
      new Promise((resolve) => {
        setTimeout(() => {
          resolve({
            status: 200,
            headers: { "Content-Type": "application/activity+json" },
            body: {
              "@context": "https://www.w3.org/ns/activitystreams",
              type: "Note",
              content: "Slow response",
            },
          });
        }, 1000);
      }),
  );

  await t.step("direct object fetch cancellation", async () => {
    const controller = new AbortController();
    const promise = lookupObject("https://example.com/slow-object", {
      contextLoader: mockDocumentLoader,
      signal: controller.signal,
    });

    controller.abort();
    assertEquals(await promise, null);
  });

  fetchMock.hardReset();
  fetchMock.removeRoutes();
});

test("traverseCollection()", {