shineout
Version:
A components library for React
24 lines • 1 kB
JavaScript
import { render } from '@testing-library/react';
export function classLengthTest(container, name, nums) {
expect(container.querySelectorAll(name).length).toBe(nums);
}
export function structureTestInContainer(container, attributes) {
attributes.forEach(function (value) {
classLengthTest(container, value.attribute, value.num);
});
}
export default function structureTest(Component, attributes) {
test('should render when not set attribute', function () {
var _render = render(Component),
container = _render.container;
structureTestInContainer(container, attributes);
});
}
export function inputTest(Component, attributes) {
var _render2 = render(Component),
container = _render2.container;
attributes.forEach(function (value) {
var _container$querySelec;
expect((_container$querySelec = container.querySelector('input')) === null || _container$querySelec === void 0 ? void 0 : _container$querySelec.getAttribute(value.attribute)).toBe(value.value);
});
}