From 15e3d04215fdab899c0fc0b8aeeb77419c518f9b Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 20:17:42 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7tracks.spec.ts=20-=20check=20if=20t?= =?UTF-8?q?rack=20was=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #17 --- src/tests/tracks.spec.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/tests/tracks.spec.ts b/src/tests/tracks.spec.ts index e9ebad7..6774742 100644 --- a/src/tests/tracks.spec.ts +++ b/src/tests/tracks.spec.ts @@ -2,7 +2,7 @@ import axios from 'axios'; describe('GET /api/tracks', () => { it('basic get should return 200', async () => { - const res = await axios.get('http://localhost:4010/api/tracks', { validateStatus: undefined }); + const res = await axios.get('http://localhost:4010/api/tracks'); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); @@ -10,7 +10,7 @@ describe('GET /api/tracks', () => { const res = await axios.post('http://localhost:4010/api/tracks', { "name": "string", "distance": 400 - }, { validateStatus: undefined }); + }); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); @@ -29,8 +29,19 @@ describe('POST /api/tracks', () => { const res = await axios.post('http://localhost:4010/api/tracks', { "name": "string", "distance": 400 - }, { validateStatus: undefined }); + }); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json") }); + it('check if track was added', async () => { + const res = await axios.get('http://localhost:4010/api/tracks'); + expect(res.status).toEqual(200); + expect(res.headers['content-type']).toContain("application/json") + let added_track = res.data[res.data.length - 1] + delete added_track.id + expect(added_track).toEqual({ + "name": "string", + "distance": 400 + }) + }); });