Find a radio button
Default Checked Props: id and name
propValue(String): Value is compared with the values of the checked props to assert a match.options(Object): Optional.
propToCheck(String): Name of prop to check against instead of the default checked props.
ReactWrapper for an input React element whose:
idornameprop value equalspropValuetypeprop value equals'radio'
If options.propToCheck is specified, then the method returns a
ReactWrapper for an input React element whose:
- value for the prop specified by
options.propToCheckequalspropValue typeprop value equals'radio'
import React from 'react'
import Page from 'react-page-object'
const App = () => (
<div>
<input
id="input-id"
type="radio"
/>
<input
name="input-name"
type="radio"
/>
<input
className="input-class"
type="radio"
/>
</div>
)
describe('findWrapperForChoose', () => {
let page, wrapper
beforeEach(() => {
page = new Page(<App />)
})
afterEach(() => {
page.destroy()
})
it('finds wrapper - targeting id', () => {
wrapper = page.findWrapperForChoose('input-id')
expect(wrapper.exists()).toBe(true)
})
it('finds wrapper - targeting name', () => {
wrapper = page.findWrapperForChoose('input-name')
expect(wrapper.exists()).toBe(true)
})
it('finds wrapper - targeting non-default prop', () => {
wrapper = page.findWrapperForChoose('input-class')
expect(wrapper.exists()).toBe(false)
wrapper = page.findWrapperForChoose('input-class', { propToCheck: 'className' })
expect(wrapper.exists()).toBe(true)
})
})