UNPKG

atomico

Version:

Atomico is a small library for the creation of interfaces based on web-components, only using functions and hooks.

33 lines (22 loc) 738 B
import { h, useRef } from "../../core/core"; import { customElementScope } from "../utils"; describe("useRef", () => { it("current ref", async () => { let instances = []; function Wc() { let ref = useRef(); instances.push(ref); return <host ref={ref} />; } let node = customElementScope(Wc); document.body.appendChild(node); await node.rendered; expect(instances[0].current).toBe(node); node.update(); await node.rendered; expect( instances.every(instance => instance === instances[0]) ).toBeTruthy(); expect(instances.length).toBe(2); }); });