unit-tests
This commit is contained in:
parent
b8ef87fc83
commit
b06a6ec07e
15849
package-lock.json
generated
Normal file
15849
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
src/components/__tests__/SelectMenu.test.jsx
Normal file
25
src/components/__tests__/SelectMenu.test.jsx
Normal file
@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import { cleanup, fireEvent, waitForElement, screen } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import { customRender,customRenderCAS } from '../../customRender';
|
||||
import {SelectMenu} from '../SelectMenu';
|
||||
import { Select } from '@material-ui/core';
|
||||
|
||||
beforeAll(() => {
|
||||
delete window.location;
|
||||
window.location = { replace: jest.fn() };
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
window.location = location;
|
||||
});
|
||||
|
||||
test('not render component for student', async () => {
|
||||
customRender(<SelectMenu/>);
|
||||
expect(screen.queryByText(/przedmioty/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('not render component for deanery', async () => {
|
||||
customRenderCAS(<SelectMenu/>);
|
||||
expect(screen.queryByText(/przedmioty/i)).not.toBeInTheDocument();
|
||||
});
|
@ -18,12 +18,21 @@ test('renders component', async () => {
|
||||
expect(screen.getByText(/plan na plan/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// test('calculate results after user types value', async () => {
|
||||
// const { getByLabelText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />);
|
||||
// const input = getByLabelText('xd');
|
||||
// fireEvent.change(input, { target: { value: '122' } });
|
||||
// console.log(debug());
|
||||
// const textNode = await waitForElement(() => getByText('asdasdsa'));
|
||||
// console.log(debug());
|
||||
// expect(textNode).toBeInTheDocument();
|
||||
// });
|
||||
test('input should display default placeholder for student', async () => {
|
||||
const { getByPlaceholderText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />);
|
||||
const input = getByPlaceholderText('Wyszukaj przedmioty...');
|
||||
// fireEvent.change(input, { target: { value: '122' } });
|
||||
// console.log(debug());
|
||||
// const textNode = await waitForElement(() => getByText('asdasdsa'));
|
||||
// console.log(debug());
|
||||
expect(input).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('input should display changed value', async () => {
|
||||
const { getByPlaceholderText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />);
|
||||
const input = getByPlaceholderText('Wyszukaj przedmioty...');
|
||||
fireEvent.change(input, { target: { value: '122' } });
|
||||
// console.log(debug());
|
||||
// console.log(debug());
|
||||
expect(input.value).toBe("122");
|
||||
});
|
||||
|
@ -16,3 +16,18 @@ export const customRender = (ui, CASValue = {}, studentsValue = {}, coursesValue
|
||||
</SnackbarProvider>,
|
||||
);
|
||||
};
|
||||
|
||||
export const customRenderCAS = (ui, CASValue = {}, studentsValue = {}, coursesValue = {}) => {
|
||||
|
||||
const user={authorityRole: "DEANERY", email: "test@test.pl", id: "123"}
|
||||
|
||||
return render(
|
||||
<SnackbarProvider>
|
||||
<CASProvider value={{user}}>
|
||||
<StudentsProvider value={50}>
|
||||
<CoursesProvider value={100}>{ui}</CoursesProvider>
|
||||
</StudentsProvider>
|
||||
</CASProvider>
|
||||
</SnackbarProvider>,
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user