Skip to main content
4 of 5
deleted 144 characters in body
Bryan Oakley
  • 25.4k
  • 5
  • 66
  • 89

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection works. You are testing that savePeople fulfills the promise it makes through its contract.

Imagine this scenario: someone does a big refactor of the code base, and accidentally removes the forEach part of the implementation so that it always only saves the first item. Wouldn't you want a unit test to catch that?

Bryan Oakley
  • 25.4k
  • 5
  • 66
  • 89