import * as React from 'react'; import * as ReactDOM from 'react-dom'; import LoadingButton from '../components/LoadingButton/index'; import { render, cleanup, Simulate } from 'react-testing-library'; beforeEach(cleanup); describe('Loading button tests', () => { it('01- LoadingButton renders corretly', () => { const clicked = jest.fn(); const { getByTestId } = render(
); expect(getByTestId('loadingBtn').textContent).toBe('test'); }) it('02- clicked', () => { const clicked = jest.fn(); const { getByTestId } = render( ) Simulate.click(getByTestId('loadingBtn')); expect(clicked).toHaveBeenCalled(); }); it('03- disabled click not called', () => { const clicked = jest.fn(); const { getByTestId } = render( , ) Simulate.click(getByTestId('loadingBtn')); expect(clicked).not.toHaveBeenCalled(); }); it('04- loading click not called', () => { const clicked = jest.fn(); const { getByTestId } = render( , ) Simulate.click(getByTestId('loadingBtn')); expect(clicked).not.toHaveBeenCalled(); }); it('05- LoadingButton Snapshot', () => { const clicked = jest.fn(); const { container } = render(
); expect(container).toMatchSnapshot(); }) })