38 lines
939 B
JavaScript
38 lines
939 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 no rows on mount", () => {
|
|
act(() => {
|
|
render(<TableBody />, container);
|
|
});
|
|
expect(container.getElementsByTagName("tr").length).toBe(0);
|
|
});
|