PUT
The modifyPerson has to return the person when it is done, so instead of writing another call to our DynamoDB, we are going to use the getPerson function we made earlier. This means that in the test we are going to want to stub it.
The getPersonStub is going to resolve to an empty object because you’ll notice that we never take information out of it and when we use it we will just say “await exports.getPerson(req, res)” not “response = await exports.getPerson(req, res).”
Then, let’s finish our test:
The 404 test should be a lot more familiar and simple:
Nice, all your tests are written! Let’s go write one more function.
The modifyPerson function will be like a mix of the addPerson and getPerson functions because you will need to check if the person is there and then update the person. You don’t need to get the name of the person from Persons API though because you already have it.
Almost done. Run your tests and see if they all work now.
Nice!
Push your changes to GitHub and then take some time to try all of your requests to the API to make sure they all work.