dimanche 23 décembre 2018

Jest Enzyme tesing, passing props as obj function and expect return for test

I have login component, and

MobileNumber as subComponent,

I am passing props details to the MobileComponent from LoginComponent

login.js

setHeaderInfo = () => {
    this.setState({
      showHeader: true,
      headerContent: {
        headerContent: {
         showBckBtn: true,
         headerTitle: 'Next'
        },
        headerTitle
      }
    })
  }
return(
<MobileComponent setHeaderInfo={this.setHeaderInfo}>
) 

Now for testing js :

  let wrapper = shallow(<Login  />)

  const MobileNumberComponent = wrapper.find('MobileNumberComponent')

  it('header Title text checking', () => {
    MobileNumberComponent.props().setHeaderInfo( () => ({setHeaderInfo: {
      showHeader: true,
      headerContent: {
        showBckBtn: true,
        headerTitle: 'Next'
        }
    }}))
  })

Here console.log for

    console.log(MobileNumberComponent.debug())
<MobileNumberComponent setHeaderInfo={[Function]} />

I have passed the function here... But how could I expect that output... whether my test header is set or not as 'Next'..?

Aucun commentaire:

Enregistrer un commentaire