From 4ff6f8c54007aa01b94f428eef0c6abdaa0c29ee Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:32:15 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=99=20nodemon=20config=20-=20ignore?= =?UTF-8?q?=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- package.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8674353..4c70efb 100644 --- a/package.json +++ b/package.json @@ -68,5 +68,12 @@ "build": "tsc", "docs": "typedoc --out docs src", "test": "jest" + }, + "nodemonConfig": { + "ignore": [ + "src/tests/*", + "docs/*" + ], + "delay": "2500" } -} +} \ No newline at end of file From 29acabfca362ea7e13f7435b171ab3ac2d12daad Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:32:38 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A7=AAtracks.spec.ts=20-=20adding=20+?= =?UTF-8?q?=20getting=20+=20updating=20tracks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- src/tests/tracks.spec.ts | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts index a196e5b..bd36eaf 100644 --- a/src/tests/tracks.spec.ts +++ b/src/tests/tracks.spec.ts @@ -56,3 +56,47 @@ describe('adding + getting tracks', () => { }) }); }); +// --------------- +describe('adding + getting + updating', () => { + let added_track_id + it('correct distance input should return 200', async () => { + const res = await axios.post('http://localhost:4010/api/tracks', { + "name": "string", + "distance": 1500 + }); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + }); + it('get should return 200', async () => { + const res1 = await axios.get('http://localhost:4010/api/tracks'); + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + let added_track = res1.data[res1.data.length - 1] + added_track_id = added_track.id + delete added_track.id + expect(added_track).toEqual({ + "name": "string", + "distance": 1500 + }) + }) + it('get should return 200', async () => { + const res2 = await axios.put('http://localhost:4010/api/tracks/' + added_track_id, { + "id": added_track_id, + "name": "apitrack", + "distance": 5100 + }); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json") + }) + it('get should return 200', async () => { + const res3 = await axios.get('http://localhost:4010/api/tracks'); + expect(res3.status).toEqual(200); + expect(res3.headers['content-type']).toContain("application/json") + let added_track2 = res3.data[res3.data.length - 1] + delete added_track2.id + expect(added_track2).toEqual({ + "name": "apitrack", + "distance": 5100 + }) + }); +});