2021-04-27 20:24:58 +03:00

38 lines
940 B
JavaScript

import React from "react";
import { render, unmountComponentAtNode } from "react-dom";
import { act } from "react-dom/test-utils";
import TableBody from "./control";
let container = null;
let table = null;
let load = null;
beforeEach(() => {
table = document.createElement("table");
container = document.createElement("tbody");
container.id = "tbody";
table.appendChild(container);
load = document.createElement("p");
load.innerHTML = "Данные загружаются";
document.body.appendChild(table);
document.body.appendChild(load);
jest.useFakeTimers();
});
afterEach(() => {
unmountComponentAtNode(container);
container.remove();
table.remove();
load.remove();
container = null;
table = null;
load = null;
jest.useRealTimers();
});
it("has rows on mount", () => {
act(() => {
render(<TableBody />, container);
});
expect(container.getElementsByTagName("tr").length).not.toBe(0);
});