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);
});
});
Also in JavaScript:
- interpolation react
- access-control-allow-origin
- memento database javascript list
- how to get window size in react js
- react native settimeout
- how to validate date in react
- node js get files in dir
- how to find a name of class from page in jquery
- defer parsing of javascript wordpress
- react lifecycle
- Cannot deserialize the current JSON array (e.g. [1,2,3]) into type
- javascript trap focus
- javascript list class properties
- append div to another div jquery
- react create list of array in react
- vuejs show content on loaded
- javascript extend object
- how to add json data to xmlhttprequest
- how to return ascending array using for loop in js
- How to check if a member has a role discord.js
- get user time using timezone javascript
- codemirror get object from textarea
- keyup function in jquery
- deutsches ajax framework