This commit is contained in:
wrzesinski-hubert 2021-01-14 15:02:28 +01:00
parent 78e63ce587
commit afd809a9ec
4 changed files with 31 additions and 6 deletions

View File

@ -0,0 +1,20 @@
import React from 'react';
import { cleanup, fireEvent, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { customRender } from '../../customRender';
import { Admin } from '../Admin';
beforeAll(() => {
delete window.location;
window.location = { replace: jest.fn() };
});
afterAll(() => {
window.location = location;
});
test('renders component', async () => {
const addItem = jest.fn();
customRender(<Admin />);
expect(screen.getByText(/Pokaż plan/i)).toBeInTheDocument();
});

View File

@ -16,5 +16,5 @@ afterAll(() => {
test('renders component', async () => {
const addItem = jest.fn();
customRender(<Scheduler/>);
expect(screen.getByText(/chuj/i)).toBeInTheDocument();
expect(screen.getByText(/Poniedziałek/i)).toBeInTheDocument();
});

View File

@ -20,19 +20,22 @@ test('renders component', async () => {
test('input should display default placeholder for student', async () => {
const { getByPlaceholderText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />);
const input = getByPlaceholderText('Wyszukaj przedmioty...');
setTimeout(()=>{const input = getByPlaceholderText('Wyszukaj przedmioty...');
expect(input).toBeInTheDocument();},2000);
// 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' } });
setTimeout(()=>{ const input = getByPlaceholderText('Wyszukaj przedmioty...');
fireEvent.change(input, { target: { value: '122' } });expect(input.value).toBe("122");},2000);
// console.log(debug());
// console.log(debug());
expect(input.value).toBe("122");
});

View File

@ -222,6 +222,8 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
}, 600);
}, []);
console.log("123,",userID,courses,basket)
return (
<coursesContext.Provider
value={{