Skip to content

Latest commit

 

History

History
71 lines (51 loc) · 1.9 KB

findWrapperForClickButton.md

File metadata and controls

71 lines (51 loc) · 1.9 KB

.findWrapperForClickButton(propValue[, options]) => ReactWrapper

Find a button

Default Checked Props: id and children

Arguments

  1. propValue (String): Value is compared with the values of the checked props to assert a match.
  2. options (Object): Optional.
  • propToCheck (String): Name of prop to check against instead of the default checked props.

Returns

ReactWrapper for a button React element whose:

  1. id or children prop value equals propValue

If options.propToCheck is specified, then the method returns a ReactWrapper for a button React element whose:

  1. value for the prop specified by options.propToCheck equals propValue

Related Methods

Example in Jest

import React from 'react'
import Page from 'react-page-object'

const App = () => (
  <div>
    <button id="button-id" />
    <button>button text</button>
    <button className="button-class" />
  </div>
)

describe('findWrapperForClickButton', () => {
  let page, wrapper

  beforeEach(() => {
    page = new Page(<App />)
  })

  afterEach(() => {
    page.destroy()
  })

  it('finds wrapper - targeting id', () => {
    wrapper = page.findWrapperForClickButton('button-id')
    expect(wrapper.exists()).toBe(true)
  })

  it('finds wrapper - targeting children', () => {
    wrapper = page.findWrapperForClickButton('button text')
    expect(wrapper.exists()).toBe(true)
  })

  it('finds wrapper - targeting non-default prop', () => {
    wrapper = page.findWrapperForClickButton('button-class')
    expect(wrapper.exists()).toBe(false)

    wrapper = page.findWrapperForClickButton('button-class', { propToCheck: 'className' })
    expect(wrapper.exists()).toBe(true)
  })
})