Repository URL to install this package:
|
Version:
4.0.0-alpha.6 ▾
|
import React from 'react';
import { mount } from 'enzyme';
import Checkbox from '../Checkbox';
describe('Checkbox', () => {
it('calls onToggled handler with correct value pulled from event target', async () => {
const toggleHandlerMock = jest.fn();
const component = mount(<Checkbox label="Test" onToggled={toggleHandlerMock} />);
const input = await component.find('input');
input.simulate('change', { target: { checked: true } });
expect(toggleHandlerMock).toHaveBeenLastCalledWith(true);
input.simulate('change', { target: { checked: false } });
expect(toggleHandlerMock).toHaveBeenLastCalledWith(false);
});
});