MCPcopy Create free account
hub / github.com/backnotprop/plannotator / mountSession

Function mountSession

packages/ui/annotationDraftPersistence.test.tsx:192–216  ·  view source on GitHub ↗

Mounts a fresh hook instance and flushes the on-mount draft GET.

(opts: HookOptions)

Source from the content-addressed store, hash-verified

190
191/** Mounts a fresh hook instance and flushes the on-mount draft GET. */
192async function mountSession(opts: HookOptions): Promise<Session> {
193 const host = document.createElement('div');
194 document.body.appendChild(host);
195 const resultRef: { current: HookResult | null } = { current: null };
196 let root: Root;
197 await act(async () => {
198 root = createRoot(host);
199 root.render(<Harness opts={opts} resultRef={resultRef} />);
200 });
201 await tick(0); // let the GET .then chain settle (sets hasMountedRef)
202 return {
203 result: resultRef,
204 rerender: async (next: HookOptions) => {
205 await act(async () => {
206 root.render(<Harness opts={next} resultRef={resultRef} />);
207 });
208 },
209 unmount: async () => {
210 await act(async () => {
211 root.unmount();
212 });
213 host.remove();
214 },
215 };
216}
217
218// ---------------------------------------------------------------------------
219// Tests

Calls 3

renderMethod · 0.80
tickFunction · 0.70
removeMethod · 0.65

Tested by

no test coverage detected