UNPKG

reblend-testing-library

Version:

Simple and complete Reblendjs testing utilities that encourage good testing practices.

38 lines (36 loc) 1.36 kB
"use strict"; var _reblendjs = require("reblendjs"); var _ = require("../"); // these are created once per test suite and reused for each case let treeA, treeB; beforeAll(() => { treeA = document.createElement('div'); treeB = document.createElement('div'); document.body.appendChild(treeA); document.body.appendChild(treeB); }); afterAll(() => { treeA.parentNode.removeChild(treeA); treeB.parentNode.removeChild(treeB); }); test('baseElement isolates trees from one another', async () => { const { getByText: getByTextInA } = await (0, _.render)(_reblendjs.Reblend.construct.bind(this)("div", null, "Jekyll"), { baseElement: treeA }); const { getByText: getByTextInB } = await (0, _.render)(_reblendjs.Reblend.construct.bind(this)("div", null, "Hyde"), { baseElement: treeB }); expect(() => getByTextInA('Jekyll')).not.toThrow('Unable to find an element with the text: Jekyll.'); expect(() => getByTextInB('Jekyll')).toThrow('Unable to find an element with the text: Jekyll.'); expect(() => getByTextInA('Hyde')).toThrow('Unable to find an element with the text: Hyde.'); expect(() => getByTextInB('Hyde')).not.toThrow('Unable to find an element with the text: Hyde.'); }); // https://github.com/testing-library/eslint-plugin-testing-library/issues/188 /* eslint testing-library/prefer-screen-queries: "off", */