Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
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);
  });
});