UNPKG

@eureca/eureca-ui

Version:

UI component library of Eureca's user and admin apps

51 lines (45 loc) 1.31 kB
import React from 'react'; import { CronogramTable } from '..'; import { render, fireEvent } from '@testing-library/react'; import { MuiPickersUtilsProvider } from '@material-ui/pickers'; import DateFnsUtils from '@date-io/date-fns'; import { ptBR } from 'date-fns/locale'; const tableData = [ { description: 'Início das inscrições', deadline: new Date(21, 4, 25), phase: 'Online', show: true, id: 1, }, { description: 'Presencial em SP', deadline: new Date(22, 0, 25), phase: 'Presencial', show: true, id: 2, }, { description: 'Início do estágio', deadline: new Date(22, 1, 14), phase: 'Geral', show: true, id: 3, }, ]; function renderCronogramTable(props) { return render( <MuiPickersUtilsProvider utils={DateFnsUtils} locale={ptBR}> <CronogramTable initialData={tableData} {...props} /> </MuiPickersUtilsProvider> ); } describe('Accordion component', () => { it('toggles visibility', () => { const { getAllByTestId } = renderCronogramTable({ onChange: jest.fn(value => value) }); const [firstButton] = getAllByTestId('visibility-testid'); expect(firstButton.textContent).toBe('Visível'); fireEvent.click(firstButton); expect(firstButton.textContent).toBe('Invisível'); }); });