I have this test:
it('calls addTheItem when clicked', () => {
const button = wrapper.find('.addBtn').simulate('click')
expect(addTheItemStub.called).to.equal(true)
});
This is my code
<button
className="addBtn"
onClick={() => {this.addTheItem(inputValue); this.clearInput()}}
>
Add Item
</button>
This code works when I play around with it. just the test isn't passing.
also in my beforeEach:
const addTheItemStub = sinon.spy();
const addItemStub = sinon.spy();
const usingEnterKeyStub = sinon.spy();
beforeEach(() => {
wrapper = shallow(
<Container
addTheItem={addTheItemStub}
addItem={addItemStub}
items={itemsStub}
usingEnterKey={usingEnterKeyStub}
/>
)
});
I'm stubbing it out. I'm expecting the stub to be called.
but it's expecting it to be not called or false. what am i doing wrong?
Aucun commentaire:
Enregistrer un commentaire