vendredi 27 janvier 2017

How to mock a method which being called from render method using shallow (enzyme)

I need to Mock getZvalue so , when i do a shallow based on z value i will try to render something different . How do i test it . Below is sample code . can i spy this method to return a value

  class AbcComponent extends React.Component{
    render(){
    const z= this.getZValue();
    return <div>{z}</div>

    }

    getZValue(){
    //some calculations 
    }
    }


    describe('AbcComponent',()=>{

    it('Test AbcComponent',()=>{

    const wrapper= shallow<AbcComponent/>


    )


    })

Aucun commentaire:

Enregistrer un commentaire