mardi 24 février 2015

Unit testing methods with side effect

As far as I know "unit test should not be testing internal implementation details in order to not complicate the refactoring of the method". So, how can I test this method?



deleteOrder = (order) ->
backendService('deleteOrder', order.id)
cacheOfOrders.delete(order)


From my unit testing environment (jasmine) I can call deleteOrder and mock the backend call, but I can't access to the cacheOfOrders. I wanted to check that the cacheOfOrders.length was reduced in one. Maybe I'm doing it wrong and I should not test internal details, but what if I have one method like the previous one but without a backend call?


Aucun commentaire:

Enregistrer un commentaire