import { expect, test } from "vitest" import { fromPromiseAsync, fromPromiseSync, signal, toPromise } from "#Source/reactor/index.ts" test("fromPromiseAsync operator should work correctly", async () => { const a = await fromPromiseAsync({ target: Promise.resolve(42) }) expect(a.get()).toBe(42) }) test("fromPromiseSync operator should work correctly", async () => { const a = fromPromiseSync({ target: Promise.resolve(42) }) const aPromise = toPromise({ target: a }) const value = await aPromise expect(value).toBe(42) }) test("toPromise operator should work correctly", async () => { const a = signal(() => 0) const aPromise = toPromise({ target: a }) a.set(1) const value1 = await aPromise expect(value1).toBe(1) const aPromise2 = toPromise({ target: a }) a.set(2) const value2 = await aPromise2 expect(value2).toBe(2) a.set(3) expect(value2).toBe(2) })