| @@ -5,14 +5,20 @@ import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"; · 4 unmodified lines |
| 5 | import { isAsyncResultLoading } from "./async-result"; | 5 | import { isAsyncResultLoading } from "./async-result"; |
| 6 | | 6 | |
| 7 | describe("isAsyncResultLoading", () => { | 7 | describe("isAsyncResultLoading", () => { |
| 8 | it("treats initial and waiting async results as loading", () => { | 8 | it("treats initial and waiting-without-value async results as loading", () => { |
| 9 | expect(isAsyncResultLoading(AsyncResult.initial())).toBe(true); | 9 | expect(isAsyncResultLoading(AsyncResult.initial())).toBe(true); |
| 10 | expect(isAsyncResultLoading(AsyncResult.initial(true))).toBe(true); | 10 | expect(isAsyncResultLoading(AsyncResult.initial(true))).toBe(true); |
| 11 | expect(isAsyncResultLoading(AsyncResult.success(["cached"], { waiting: true }))).toBe(true); | 11 | expect(isAsyncResultLoading(AsyncResult.failure(Cause.fail("boom"), { waiting: true }))).toBe( |
| | 12 | true, |
| | 13 | ); |
| 12 | }); | 14 | }); |
| 13 | | 15 | |
| 14 | it("does not treat settled success or failure as loading", () => { | 16 | it("does not treat settled success or failure as loading", () => { |
| 15 | expect(isAsyncResultLoading(AsyncResult.success(["ready"]))).toBe(false); | 17 | expect(isAsyncResultLoading(AsyncResult.success(["ready"]))).toBe(false); |
| 16 | expect(isAsyncResultLoading(AsyncResult.failure(Cause.fail("boom")))).toBe(false); | 18 | expect(isAsyncResultLoading(AsyncResult.failure(Cause.fail("boom")))).toBe(false); |
| 17 | }); | 19 | }); |
| | 20 | |
| | 21 | it("keeps stale values rendered while a refresh is waiting", () => { |
| | 22 | expect(isAsyncResultLoading(AsyncResult.success(["cached"], { waiting: true }))).toBe(false); |
| | 23 | }); |
| 18 | }); | 24 | }); |