Fill in a textarea
Default Checked Props: id
, name
, and placeholder
The propValue
and options
arguments are passed to
.findWrapperForFillInTextarea
to find a
ReactWrapper
. The ReactWrapper
will be
used to simulate events.
propValue
(String
): Value is compared with the values of the checked props to assert a match.eventTargetValue
(String
): Value which will equalevent.target.value
inonChange
event handlers triggered by the simulatedchange
event.options
(Object
): Optional.
propToCheck
(String
): Name of prop to check against instead of the default checked props.
Page
object which invoked the method. This allow the method to be chained
with another Page
object method.
If a ReactWrapper
is found by
.findWrapperForFillInTextarea
, then the following events will
be simulated on the ReactWrapper
's React element:
blur
event on the React element which is focused. This will occur if there is a focused React element and it is not the same as theReactWrapper
's React element.focus
event on theReactWrapper
's React element unless it is already in focus.change
event on theReactWrapper
's React element. ForonChange
event handlers triggered by this simulatedchange
event,event.target.value
will equaleventTargetValue
.
If no ReactWrapper
is found, then an error is thrown.
import React, { Component } from 'react'
import Page from 'react-page-object'
class App extends Component {
state = { text: '' }
onChange = event => this.setState({ text: event.target.value })
render() {
return (
<div>
{this.state.text}
<textarea id="textarea-id" onChange={this.onChange} />
<textarea name="textarea-name" onChange={this.onChange} />
<textarea placeholder="textarea-placeholder" onChange={this.onChange} />
<textarea className="textarea-class" onChange={this.onChange} />
</div>
)
}
}
describe('fillInTextarea', () => {
let page
beforeEach(() => {
page = new Page(<App />)
})
afterEach(() => {
page.destroy()
})
it('fills in the textarea - targeting id', () => {
page.fillInTextarea('textarea-id', 'hello')
expect(page.content()).toMatch(/hello/)
})
it('fills in the textarea - targeting name', () => {
page.fillInTextarea('textarea-name', 'hello')
expect(page.content()).toMatch(/hello/)
})
it('fills in the textarea - targeting placeholder', () => {
page.fillInTextarea('textarea-placeholder', 'hello')
expect(page.content()).toMatch(/hello/)
})
it('fills in the textarea - targeting non-default prop', () => {
page.fillInTextarea('textarea-class', 'hello', { propToCheck: 'className' })
expect(page.content()).toMatch(/hello/)
})
})