Update task documentation and test fixes

- Update Tasks.md with current progress and status
- Fix useListData hook tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-04-25 19:34:16 +02:00
parent 6490e9d3df
commit 3b527244aa
2 changed files with 33 additions and 20 deletions

View File

@@ -76,4 +76,37 @@ describe("useListData", () => {
expect(fetcher).toHaveBeenCalledTimes(2);
expect(result.current.items).toEqual(["second"]);
});
it("does not update state when signal is aborted before resolution", async () => {
const abortedSignals: AbortSignal[] = [];
const fetcher = vi.fn().mockImplementation(async (signal: AbortSignal) => {
abortedSignals.push(signal);
// Simulate a delay
await new Promise((resolve) => setTimeout(resolve, 50));
return { items: ["late"] };
});
const selector = vi.fn((response: { items: string[] }) => response.items);
const { result, unmount } = renderHook(() =>
useListData({
fetcher,
selector,
errorMessage: "Failed to load",
})
);
// Unmount immediately to trigger abort
await act(async () => {
await Promise.resolve();
});
unmount();
// Verify at least one signal was collected and it was aborted
expect(abortedSignals.length).toBeGreaterThan(0);
const lastSignal = abortedSignals[abortedSignals.length - 1];
expect(lastSignal != null && lastSignal.aborted).toBe(true);
// Items should not be updated after abort
expect(result.current.items).toEqual([]);
});
});