I got this test to pass when it shouldn’t
I don’t think the test checks for the second part correctly. “If no date is supplied, the current date will be used.”
let requireDate = new Date(date);
the date argument is req.body.date in this case and thus the code does not account for if the date is not supplied.
This creates confusion because the following tests do not pass as a result.
The following change made all the tests pass. This shows that test 7 is the issue that makes the other tests not pass and thus test 7 should not have passed in the first place.
let requireDate = date? new Date(date) : new Date();
Here are my repls:
Let me know if more information is needed.
I see your point. Look here and scroll down to the appropriate test and you’ll see it only tests with a date of
1990-01-01 and not an unspecified date so it’s just checking the response format and not the optional date.
I think the problem would be that adding a date check here would introduce another timezone offset problem in this test like in the one that checks for string dates in the
GET /api/users/:id/logs test. If you look at all the other tests you mention, none of them check the dates.
This ties into and has the same ultimate solution as this issue.