/* eslint-disable function-paren-newline, comma-dangle */ import React from 'react' import renderWithTheme from '../../testHelper' import CheckboxGroupWithNSupFields from '../CheckboxGroupWithNSupFields' describe('CheckboxGroupWithNSupFields', () => { it('renders a CheckboxGroupWithNSupFields', () => { const tree = renderWithTheme( (
I am a the A supplemental field!
) }, { index: 1, showSupplementalValue: '2', render: () => (
I am a the B supplemental field!
) }, ]} /> ) expect(tree).toMatchSnapshot() }) it('renders a CheckboxGroupWithNSupFields with a value pre selected', () => { const tree = renderWithTheme( (
I am a the A supplemental field!
) }, { index: 1, showSupplementalValue: '2', render: () => (
I am a the B supplemental field!
) }, ]} /> ) expect(tree).toMatchSnapshot() }) describe('events', () => { it('handles onChange', () => { const wrapper = mount( (
I am a the A supplemental field!
) }, { index: 1, showSupplementalValue: '2', render: () => (
I am a the B supplemental field!
) }, ]} /> ) const checkbox = wrapper.find('input#test-checkbox-with-sup-One') checkbox.simulate('change', { target: { checked: true, value: '2' } }) expect(wrapper.state('showingSupplementals')).toEqual([ expect.objectContaining({ index: 1, showSupplementalValue: '2' }) ]) checkbox.simulate('change', { target: { checked: true, value: '1' } }) expect(wrapper.state('showingSupplementals')).toEqual([ expect.objectContaining({ index: 0, showSupplementalValue: '1' }), expect.objectContaining({ index: 1, showSupplementalValue: '2' }) ]) checkbox.simulate('change', { target: { checked: false, value: '1' } }) expect(wrapper.state('showingSupplementals')).toEqual([ expect.objectContaining({ index: 1, showSupplementalValue: '2' }) ]) }) }) })