fix(curriculum): add test to exercise tracker (#44862)
* fix#44806: add test to exercise tracker * Fix typo in test Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8711fbad8e
commit
16f7567827
@@ -568,11 +568,11 @@ async (getUserInput) => {
|
|||||||
const addExerciseTwoRes = await fetch(url + `/api/users/${_id}/exercises`, {
|
const addExerciseTwoRes = await fetch(url + `/api/users/${_id}/exercises`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
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) {
|
if (addExerciseRes.ok && addExerciseTwoRes.ok) {
|
||||||
const logRes = await fetch(
|
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) {
|
if (logRes.ok) {
|
||||||
const { log } = await logRes.json();
|
const { log } = await logRes.json();
|
||||||
@@ -591,6 +591,16 @@ async (getUserInput) => {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(`${limitRes.status} ${limitRes.statusText}`);
|
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 {
|
} else {
|
||||||
throw new Error(`${res.status} ${res.statusText}`);
|
throw new Error(`${res.status} ${res.statusText}`);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user