mercredi 3 août 2016

Unit test on redux that involves a firebase call

I have a actionCreator method that I would like to do unit test on. It will make a firebase call and on success or fail it will dispatch 2 methods relatively.

It looks sth like this:

export function removeItem(itemId) { 
   return dispatch => {
       return firebase.database().ref('items').child(itemId).remove()
           .then(
                 success => dispatch(updateList()),
                 error => dispatch(failRemovingItem(error))
           );
       };
}

I am following the example from redux. http://ift.tt/1Oc7Uf2

But I am not able to mock the firebase call via nock.

Does anyone have experience with unit-testing something similar?

Aucun commentaire:

Enregistrer un commentaire