Answers for "simulate click jest"

0

simulate click jest

import React from 'react';
import { shallow } from 'enzyme';
import Button from './Button';

describe('Test Button component', () => {
  it('Test click event', () => {
    const mockCallBack = jest.fn();

    const button = shallow((<Button onClick={mockCallBack}>Ok!</Button>));
    button.find('button').simulate('click');
    expect(mockCallBack.mock.calls.length).toEqual(1);
  });
});
Posted by: Guest on June-10-2020

Code answers related to "simulate click jest"

Code answers related to "Javascript"

Browse Popular Code Answers by Language