Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
  });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: last element in array javascript 
Javascript :: javascript reverse array 
Javascript :: vuejs string contains 
Javascript :: generate a sequence numbers between a range javascript 
Javascript :: immutable array sort javascript 
Javascript :: javascript check if elements of one array are in another 
Javascript :: remove duplicates from array of objects javascript 
Javascript :: lodash deep clone object 
Javascript :: regular expression to find a string between two characters 
Javascript :: How to make the width of a react native element adjust according to the contents 
Javascript :: useState settoggle 
Javascript :: javascript clone array of object 
Javascript :: angular cli create component with module 
Javascript :: js enter key event listener 
Javascript :: react toggle boolean state 
Javascript :: js open window in new tab 
Javascript :: Use multiple conditional operators in the checkSign function to check if a number is positive, negative or zero. The function should return "positive", "negative" or "zero". 
Javascript :: today in moment 
Javascript :: eof while parsing 
Javascript :: clean react app 
Javascript :: React Unmounting Lifecycle Method 
Javascript :: add variable numerically in javascript 
Javascript :: Error serializing `.list Data` returned from `getStaticProps` 
Javascript :: get element with one or another class 
Javascript :: jquery switch class 
Javascript :: express bodyparser deprecated 
Javascript :: how to use absolute path in react 
Javascript :: material ui textfield error 
Javascript :: encode in javascript 
Javascript :: register a service worker 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =