From 16f7567827644fb521132d81843db84655bc0328 Mon Sep 17 00:00:00 2001 From: Christopher Ehrlich Date: Thu, 10 Feb 2022 21:33:36 +0100 Subject: [PATCH] fix(curriculum): add test to exercise tracker (#44862) * fix#44806: add test to exercise tracker * Fix typo in test Co-authored-by: Shaun Hamilton Co-authored-by: Shaun Hamilton --- .../exercise-tracker.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/curriculum/challenges/english/05-back-end-development-and-apis/back-end-development-and-apis-projects/exercise-tracker.md b/curriculum/challenges/english/05-back-end-development-and-apis/back-end-development-and-apis-projects/exercise-tracker.md index d22ca8c0ed..9224459587 100644 --- a/curriculum/challenges/english/05-back-end-development-and-apis/back-end-development-and-apis-projects/exercise-tracker.md +++ b/curriculum/challenges/english/05-back-end-development-and-apis/back-end-development-and-apis-projects/exercise-tracker.md @@ -568,11 +568,11 @@ async (getUserInput) => { const addExerciseTwoRes = await fetch(url + `/api/users/${_id}/exercises`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - body: `description=${expected.description}&duration=${expected.duration}&date=1990-01-02` + body: `description=${expected.description}&duration=${expected.duration}&date=1990-01-03` }); if (addExerciseRes.ok && addExerciseTwoRes.ok) { const logRes = await fetch( - url + `/api/users/${_id}/logs?from=1989-12-31&to=1990-01-03` + url + `/api/users/${_id}/logs?from=1989-12-31&to=1990-01-04` ); if (logRes.ok) { const { log } = await logRes.json(); @@ -591,6 +591,16 @@ async (getUserInput) => { } else { throw new Error(`${limitRes.status} ${limitRes.statusText}`); } + const filterDateBeforeLimitRes = await fetch( + url + `/api/users/${_id}/logs?from=1990-01-02&to=1990-01-04&limit=1` + ); + if (filterDateBeforeLimitRes.ok) { + const { log } = await filterDateBeforeLimitRes.json(); + assert.isArray(log); + assert.equal(1, log.length); + } else { + throw new Error(`${filterDateBeforeLimitRes.status} ${filterDateBeforeLimitRes.statusText}`); + } } else { throw new Error(`${res.status} ${res.statusText}`); }