UNPKG

@eureca/eureca-ui

Version:

UI component library of Eureca's user and admin apps

34 lines (26 loc) 815 B
import React from 'react'; import { AddColumn } from '../add-column'; import { render, fireEvent } from '@testing-library/react'; const mockFn = jest.fn(value => value); function renderAddColumn(props) { return render(<AddColumn {...props} />); } test('trigger and return add fn by clicking in add new -> selecting option', async () => { const { getByText } = renderAddColumn({ add: mockFn, phaseOptions: [ { id: 1, value: 'presencial', label: 'Presencial', }, ], }); const button = getByText('Adicionar nova fase').parentElement; expect(button).toBeDefined(); fireEvent.click(button); const menuItem = getByText('Presencial'); expect(menuItem).toBeDefined(); fireEvent.click(menuItem); expect(mockFn).toHaveReturnedWith('Presencial'); });