Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

testing a function in jest on click react

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 :: js get innertext minus the span text 
Javascript :: pause console debugger in react 
Javascript :: javascript the event loop 
Javascript :: javascript array some 
Javascript :: javascript string 
Javascript :: for loop -2 js 
Javascript :: get data from excel using vue js 
Javascript :: dispay react component after some time 
Javascript :: nds npm 
Javascript :: odd number is javascript 
Javascript :: react-data-table-component edit action 
Javascript :: decode raw data to string nodejs 
Javascript :: react route multiple components 
Javascript :: javascript array destructuring last element 
Javascript :: set javascript 
Javascript :: detect if user is online react 
Javascript :: object promise javascript 
Javascript :: settimeout js 
Javascript :: use jquery in project using NPM 
Javascript :: extract data from object when it match with array of ids js 
Javascript :: create cookie javascript react 
Javascript :: discord.js messageUpdate 
Javascript :: decorators in javascript 
Javascript :: add object in array state react 
Javascript :: javascript integer to binary 
Javascript :: mongoose callback in save function 
Javascript :: javascript remove function from object 
Javascript :: error first line of nextjs file 
Javascript :: angular input date pattern validation 
Javascript :: show and hide element in react 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =