mardi 24 octobre 2017

Testing a function as prop inside a component

i'm trying to test a component which has some props. One of the props is a function. My component is this:

<Field
        autoOk
        formatDate={date => moment(date).format('DD-MM-YYYY')}
      />

it('renders the Date From Field Component', () => {
      expect(menuWrapper.childAt(0).prop('floatingLabelText')).to.equal('Ημερομηνία από');
      expect(menuWrapper.childAt(0).prop('component')).to.equal(DatePicker);
      expect(menuWrapper.childAt(0).prop('autoOk')).to.equal(true);
      expect(menuWrapper.childAt(0).prop('formatDate')).to.be.a('function');
      // expect(moment.calledWith('2017-12-12T00:00:00.000Z')).to.equal(false);
    });

But i can't test the last prop. Do you know how?

Aucun commentaire:

Enregistrer un commentaire