import { describe, it, expect } from "vitest"; import { render, screen, act } from "@testing-library/react"; import { Suspense, startTransition, use, useState } from "react"; import { resource } from "../../core/resource"; import { useResource } from "../../index"; import { useState as useResourceState } from "../../react-hooks/useState"; const ShouldNeverFallback = () => { throw new Error("should never fallback"); }; describe("Concurrent Mode with useResource", () => { it("should not commit useResourceState updates when render is discarded", async () => { const useTestResource = () => { return useResourceState(false); }; const TestResource = resource(useTestResource); let resolve: (value: number) => void; const suspendPromise = new Promise((r) => { resolve = r; }); function Suspender() { const value = use(suspendPromise); return value; } function App() { const [load, setLoading] = useResource(TestResource()); const [message, setMessage] = useState("none"); return ( <>