Repository URL to install this package:
|
Version:
0.14.1 ▾
|
import React from 'react'
import ReactDOM from 'react-dom'
import ReactTestUtils from 'react-dom/test-utils'
import { ToggleMolecule } from 'src/components/molecules/Toggle/ToggleMolecule'
import { toCommonState } from 'src/state/common'
describe('Test checkbox', () => {
it('should be able to toggle the checkbox and change the state', () => {
const state = toCommonState({})
const { isVisible, handleToggleVisibility } = state
const Checkbox = ReactTestUtils.renderIntoDocument(
<ToggleMolecule
name={'checkbox'}
className={'toggle-view'}
isRadio={false}
isSelected={!isVisible}
onClick={handleToggleVisibility}
/>
)
const checkboxNode = ReactDOM.findDOMNode(Checkbox)
expect(state.isVisible).toBeFalsy()
ReactTestUtils.Simulate.click(checkboxNode)
expect(state.isVisible).toBeTruthy()
ReactTestUtils.Simulate.click(checkboxNode)
expect(state.isVisible).toBeFalsy()
})
})