Chore/tests (#73)

* chore/tests: install testing libraries
* chore/tests: upgrade dependencies
* chore/tests: configure linters
* chore/tests: add basic component tests
* chore/tests: version bump
This commit is contained in:
Carlos Valente
2021-12-19 14:22:02 +01:00
committed by GitHub
parent 1e4206fcb2
commit c12bca05aa
13 changed files with 935 additions and 1358 deletions
@@ -0,0 +1,21 @@
import { render, screen } from '@testing-library/react';
import MenuBar from "../MenuBar";
import {queryClientMock} from "../../../__mocks__/QueryClient.mock";
import {QueryClientProvider} from "react-query";
const onOpenHandler = jest.fn();
const renderInMock = () => {
render(
<QueryClientProvider client={queryClientMock}>
<MenuBar onOpen={onOpenHandler} />
</QueryClientProvider>
)
};
test('check that menu bar renders correctly', () => {
// need to inject the react query provider
renderInMock();
const nButtons = screen.getAllByRole("button").length;
expect(nButtons).toBe(7);
});
@@ -0,0 +1,18 @@
import { render, screen } from '@testing-library/react';
import MenuActionButtons from "../MenuActionButtons";
const actionHandler = jest.fn();
const renderInMock = () => {
render(<MenuActionButtons actionHandler={actionHandler} />)
};
test('check that menu bar renders correctly', () => {
// need to inject the react query provider
renderInMock();
const b = screen.getByRole('button', {
name: /create menu/i
})
expect(b).toBeInTheDocument();
});
@@ -0,0 +1,21 @@
import { render, screen } from '@testing-library/react';
import MenuBar from "../MenuBar";
import {queryClientMock} from "../../../__mocks__/QueryClient.mock";
import {QueryClientProvider} from "react-query";
const onOpenHandler = jest.fn();
const renderInMock = () => {
render(
<QueryClientProvider client={queryClientMock}>
<MenuBar onOpen={onOpenHandler} />
</QueryClientProvider>
)
};
test('check that menu bar renders correctly', () => {
// need to inject the react query provider
renderInMock();
const nButtons = screen.getAllByRole("button").length;
expect(nButtons).toBe(7);
});