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?
Put another way, you aren't testing that the functions it calls work, you're testing that it calls the correct functions.