reshow-unit
Version:
Reshow Unit Test Pack
41 lines • 1.18 kB
JavaScript
var _div, _span;
import { expect } from "chai";
import { render, screen, cleanIt, jsdom } from "../index.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
describe("Test cleanIt", function () {
beforeEach(function () {
jsdom();
});
afterEach(function () {
cleanIt();
});
it("basic test", function () {
var DIV = function DIV() {
return _div || (_div = /*#__PURE__*/_jsx("div", {
role: "dom",
children: "foo"
}));
};
render(/*#__PURE__*/_jsx(DIV, {}));
expect(screen().getByRole("dom").innerHTML).to.equal("foo");
});
it("test attach", function () {
var el = document.createElement("div");
document.body.appendChild(el);
var SPAN = function SPAN() {
return _span || (_span = /*#__PURE__*/_jsx("span", {}));
};
render(/*#__PURE__*/_jsx(SPAN, {}), {
container: el
});
expect(document.body.innerHTML).to.equal("<div><span></span></div>");
document.foo = "bar";
cleanIt({
withoutJsdom: true
});
expect(document.body.innerHTML).to.equal("");
expect(document.foo).to.equal("bar");
cleanIt();
expect(document.foo).to.be.undefined;
});
});