UNPKG

reshow-unit

Version:
33 lines 1.08 kB
import _asyncToGenerator from "reshow-runtime/es/helpers/asyncToGenerator"; import { useState } from "react"; import { expect } from "chai"; import { render, screen, act, waitFor } from "../index.mjs"; import { jsx as _jsx } from "react/jsx-runtime"; describe("Test Act", function () { it("basic test", /*#__PURE__*/_asyncToGenerator(function* () { var change; var Foo = function Foo(props) { var [state, setState] = useState(); change = setState; return /*#__PURE__*/_jsx("div", { role: "dom", children: state }); }; render(/*#__PURE__*/_jsx(Foo, {})); expect(screen().getByRole("dom").outerHTML).to.equal("<div role=\"dom\"></div>"); setTimeout(function () { return console.log(1); }, 1); setTimeout(function () { return console.log(2); }, 5); setTimeout(function () { return console.log(3); }, 9); yield act(function () { return change("foo"); }, 10, true); expect(screen().getByRole("dom").outerHTML).to.equal("<div role=\"dom\">foo</div>"); })); });