diff --git a/packages/async/src/withStatusesAtom.test.ts b/packages/async/src/withStatusesAtom.test.ts index 39b40d57..05bb3e99 100644 --- a/packages/async/src/withStatusesAtom.test.ts +++ b/packages/async/src/withStatusesAtom.test.ts @@ -9,6 +9,7 @@ import { AsyncStatusesFirstPending, AsyncStatusesFulfilled, AsyncStatusesNeverPending, + AsyncStatusesNextAbortedDuringPending, AsyncStatusesRejected, asyncStatusesInitState, withStatusesAtom, @@ -210,6 +211,30 @@ test('do not reject on abort', async () => { ;`👍` //? }) +test('isEverSettled after abort', async () => { + const fetchData = reatomAsync(async () => sleep()).pipe(withAbort(), withStatusesAtom()) + const ctx = createTestCtx() + + expect(ctx.get(fetchData.statusesAtom)).toBe(asyncStatusesInitState) + await fetchData(ctx) + expect(ctx.get(fetchData.statusesAtom).isFulfilled).toBe(true) + + fetchData(ctx) + fetchData(ctx) + await null + expect(ctx.get(fetchData.statusesAtom)).toEqual({ + isPending: true, + isFulfilled: false, + isRejected: false, + isSettled: false, + + isFirstPending: false, + isEverPending: true, + isEverSettled: true, + } satisfies AsyncStatusesNextAbortedDuringPending) + ;`👍` //? +}) + test('do not reject on resource abort', async () => { const fetchData = reatomResource(async (ctx) => {}).pipe(withStatusesAtom()) const ctx = createTestCtx() diff --git a/packages/async/src/withStatusesAtom.ts b/packages/async/src/withStatusesAtom.ts index c84cdc21..d5f46482 100644 --- a/packages/async/src/withStatusesAtom.ts +++ b/packages/async/src/withStatusesAtom.ts @@ -36,6 +36,16 @@ export interface AsyncStatusesFirstAborted { isEverPending: true isEverSettled: false } +export interface AsyncStatusesNextAbortedDuringPending { + isPending: true + isFulfilled: false + isRejected: false + isSettled: false + + isFirstPending: false + isEverPending: true + isEverSettled: true +} export interface AsyncStatusesAbortedPending { isPending: true