ui-neu
Version:
Neu UI, a responsive React component library.
29 lines (28 loc) • 1.08 kB
JavaScript
import React from "react";
import { act } from "react-dom/test-utils";
import { render, unmountComponentAtNode } from "react-dom";
import { Typography } from "./Typography";
var container = null;
beforeEach(function () {
// setting up DOM element as render target
container = document.createElement("div");
document.body.appendChild(container);
});
afterEach(function () {
// cleanup on exiting
unmountComponentAtNode(container);
container.remove();
container = null;
});
var variantValue = ["h1", "h2", "h3", "h4", "h5", "h6", "subtitle1", "subtitle2", "body1", "body2"]; // Using each statement https://jestjs.io/docs/en/api#describeeachtablename-fn-timeout
// tests whether child content is rendered
describe("typography component testing", function () {
test.each(variantValue)("test Typography with %p as variant props", function (typo) {
act(function () {
render( /*#__PURE__*/React.createElement(Typography, {
variant: typo
}, "Test " + typo), container);
});
expect(container.textContent).toBe("Test " + typo);
});
});