// import { describe, expect, it, vi, beforeEach, afterEach } from "bun:test"; // import { useSWR } from "../index"; // import { effectScope } from "vue"; // function withSetup(composable: () => T): [T, () => void] { // let result: T; // const scope = effectScope(); // scope.run(() => { // result = composable(); // }); // return [result!, () => scope.stop()]; // } // // Mock fetcher // const fetcher = vi.fn((key: string) => Promise.resolve(`data-${key}`)); // describe("useSWR (Vue)", () => { // beforeEach(() => { // vi.useFakeTimers(); // fetcher.mockClear(); // }); // afterEach(() => { // vi.useRealTimers(); // }); // it("fetches data on mount", async () => { // // const { data, isLoading } = useSWR("test-key", fetcher); // const [{data, isLoading}, stop] = withSetup(() => useSWR("test-key", fetcher)); // // Initial state // expect(isLoading.value).toBe(true); // // Wait for fetch // vi.runAllTimers(); // expect(data.value).toBe("data-test-key"); // expect(isLoading.value).toBe(false); // stop(); // }); // // it("deduplicates requests", async () => { // // const [{ data: d1 }, stop1] = withSetup(() =>useSWR("dedupe-key", fetcher)); // // const [{ data: d2 }, stop2] = withSetup(() =>useSWR("dedupe-key", fetcher)); // // vi.runAllTimers(); // // expect(fetcher).toHaveBeenCalledTimes(1); // // expect(d1.value).toBe("data-dedupe-key"); // // expect(d2.value).toBe("data-dedupe-key"); // // stop1(); // // stop2(); // // }); // // it("mutates data manually", async () => { // // const { data, mutate } = useSWR("mutate-key", fetcher); // // vi.runAllTimers(); // // expect(data.value).toBe("data-mutate-key"); // // await mutate("new-data"); // // expect(data.value).toBe("new-data"); // // }); // });