ScopeMap -> ScopeRegistry
Lint / lint (push) Failing after 43s

This commit is contained in:
Julien Valverdé
2026-07-22 22:51:38 +02:00
parent c151b4608f
commit 8fed17789a
5 changed files with 43 additions and 38 deletions
@@ -4,6 +4,7 @@ import * as React from "react"
import { afterEach, describe, expect, it, vi } from "vitest"
import * as Component from "../src/Component.js"
import * as ReactRuntime from "../src/ReactRuntime.js"
import * as ScopeRegistry from "../src/ScopeRegistry.js"
class ValueService extends Context.Service<ValueService, { readonly value: string }>()("ValueService") {}
@@ -365,7 +366,7 @@ describe("Component", () => {
const setup = vi.fn()
const runtime = ReactRuntime.make(Layer.empty)
const effectRuntime = await runtime.runtime.context()
const scopeMap = Context.get(effectRuntime, Component.ScopeMap)
const scopeRegistry = Context.get(effectRuntime, ScopeRegistry.ScopeRegistry)
const pending = new Promise<void>(() => {})
const Probe = Component.makeUntraced("DiscardedSuspenseProbe")(function*() {
@@ -390,7 +391,7 @@ describe("Component", () => {
try {
await screen.findByText("fallback")
expect(setup).not.toHaveBeenCalled()
expect(HashMap.size(Effect.runSync(Ref.get(scopeMap.ref)))).toBe(0)
expect(HashMap.size(Effect.runSync(Ref.get(scopeRegistry.ref)))).toBe(0)
}
finally {
view.unmount()
@@ -398,11 +399,11 @@ describe("Component", () => {
}
})
it.fails("clears ScopeMap after a suspended render retries, commits, and unmounts", async () => {
it.fails("clears ScopeRegistry after a suspended render retries, commits, and unmounts", async () => {
const lifecycle = vi.fn<(message: string) => void>()
const runtime = ReactRuntime.make(Layer.empty)
const effectRuntime = await runtime.runtime.context()
const scopeMap = Context.get(effectRuntime, Component.ScopeMap)
const scopeRegistry = Context.get(effectRuntime, ScopeRegistry.ScopeRegistry)
let resolve!: () => void
const pending = new Promise<void>(complete => {
resolve = complete
@@ -440,7 +441,7 @@ describe("Component", () => {
await waitFor(() => expect(lifecycle).toHaveBeenCalledWith("mount"))
view.unmount()
await waitFor(() => expect(HashMap.size(Effect.runSync(Ref.get(scopeMap.ref)))).toBe(0))
await waitFor(() => expect(HashMap.size(Effect.runSync(Ref.get(scopeRegistry.ref)))).toBe(0))
expect(lifecycle.mock.calls.filter(([message]) => message === "mount")).toHaveLength(2)
expect(lifecycle.mock.calls.filter(([message]) => message === "cleanup")).toHaveLength(2)
}