Added more tests
This commit is contained in:
@@ -6,7 +6,7 @@ import * as test_data from "./test_users.json"
|
||||
import axios from "axios";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
|
||||
let mock;
|
||||
let mock = null
|
||||
let container = null
|
||||
beforeEach(() => {
|
||||
mock = new MockAdapter(axios);
|
||||
@@ -23,7 +23,7 @@ afterEach(() => {
|
||||
container = null;
|
||||
});
|
||||
|
||||
it("has only main table row without axios request", () => {
|
||||
it("has no rows without axios request", () => {
|
||||
act(() => {
|
||||
render(<Table/>, container);
|
||||
});
|
||||
@@ -67,12 +67,14 @@ it("show valid number for engineers and light agents", async () => {
|
||||
});
|
||||
|
||||
it("called one request on mount", async () => {
|
||||
let req = jest.spyOn(Table.prototype, "get_users")
|
||||
let requests = jest.spyOn(Table.prototype, "getUsers")
|
||||
await act(async () => {
|
||||
render(<Table/>, container)
|
||||
})
|
||||
expect(req).toHaveBeenCalledTimes(1)
|
||||
expect(requests).toHaveBeenCalledTimes(1)
|
||||
requests.mockRestore()
|
||||
})
|
||||
|
||||
it("checkbox count equals users from db count", async () => {
|
||||
await act(async () => {
|
||||
render(<Table/>, container)
|
||||
@@ -82,3 +84,15 @@ it("checkbox count equals users from db count", async () => {
|
||||
let users = test_data.users
|
||||
expect(checkboxes.length).toEqual(users.length)
|
||||
})
|
||||
|
||||
it("requests occur every one minute", async () => {
|
||||
jest.useFakeTimers()
|
||||
let requests = jest.spyOn(Table.prototype, "getUsers")
|
||||
await act(async () => {
|
||||
render(<Table/>, container)
|
||||
})
|
||||
jest.advanceTimersByTime(60000)
|
||||
expect(requests).toHaveBeenCalledTimes(2)
|
||||
jest.useRealTimers()
|
||||
requests.mockRestore()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user