| @@ -1,13 +1,14 @@ | ||||
| import axios from 'axios'; | ||||
| const base = "http://localhost:4010" | ||||
|  | ||||
| describe('GET /api/tracks', () => { | ||||
| 	it('basic get should return 200', async () => { | ||||
| 		const res = await axios.get('http://localhost:4010/api/tracks'); | ||||
| 		const res = await axios.get(base + '/api/tracks'); | ||||
| 		expect(res.status).toEqual(200); | ||||
| 		expect(res.headers['content-type']).toContain("application/json") | ||||
| 	}); | ||||
| 	it('correct distance input should return 200', async () => { | ||||
| 		const res = await axios.post('http://localhost:4010/api/tracks', { | ||||
| 		const res = await axios.post(base + '/api/tracks', { | ||||
| 			"name": "string", | ||||
| 			"distance": 400 | ||||
| 		}); | ||||
| @@ -18,7 +19,7 @@ describe('GET /api/tracks', () => { | ||||
| // --------------- | ||||
| describe('POST /api/tracks', () => { | ||||
| 	it('illegal distance input should return 400', async () => { | ||||
| 		const res = await axios.post('http://localhost:4010/api/tracks', { | ||||
| 		const res = await axios.post(base + '/api/tracks', { | ||||
| 			"name": "string", | ||||
| 			"distance": -1 | ||||
| 		}, { validateStatus: undefined }); | ||||
| @@ -26,7 +27,7 @@ describe('POST /api/tracks', () => { | ||||
| 		expect(res.headers['content-type']).toContain("application/json") | ||||
| 	}); | ||||
| 	it('correct distance input should return 200', async () => { | ||||
| 		const res = await axios.post('http://localhost:4010/api/tracks', { | ||||
| 		const res = await axios.post(base + '/api/tracks', { | ||||
| 			"name": "string", | ||||
| 			"distance": 400 | ||||
| 		}); | ||||
| @@ -37,7 +38,7 @@ describe('POST /api/tracks', () => { | ||||
| // --------------- | ||||
| describe('adding + getting tracks', () => { | ||||
| 	it('correct distance input should return 200', async () => { | ||||
| 		const res = await axios.post('http://localhost:4010/api/tracks', { | ||||
| 		const res = await axios.post(base + '/api/tracks', { | ||||
| 			"name": "string", | ||||
| 			"distance": 1000 | ||||
| 		}); | ||||
| @@ -45,7 +46,7 @@ describe('adding + getting tracks', () => { | ||||
| 		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'); | ||||
| 		const res = await axios.get(base + '/api/tracks'); | ||||
| 		expect(res.status).toEqual(200); | ||||
| 		expect(res.headers['content-type']).toContain("application/json") | ||||
| 		let added_track = res.data[res.data.length - 1] | ||||
| @@ -60,7 +61,7 @@ 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', { | ||||
| 		const res = await axios.post(base + '/api/tracks', { | ||||
| 			"name": "string", | ||||
| 			"distance": 1500 | ||||
| 		}); | ||||
| @@ -68,7 +69,7 @@ describe('adding + getting + updating', () => { | ||||
| 		expect(res.headers['content-type']).toContain("application/json") | ||||
| 	}); | ||||
| 	it('get should return 200', async () => { | ||||
| 		const res1 = await axios.get('http://localhost:4010/api/tracks'); | ||||
| 		const res1 = await axios.get(base + '/api/tracks'); | ||||
| 		expect(res1.status).toEqual(200); | ||||
| 		expect(res1.headers['content-type']).toContain("application/json") | ||||
| 		let added_track = res1.data[res1.data.length - 1] | ||||
| @@ -80,7 +81,7 @@ describe('adding + getting + updating', () => { | ||||
| 		}) | ||||
| 	}) | ||||
| 	it('get should return 200', async () => { | ||||
| 		const res2 = await axios.put('http://localhost:4010/api/tracks/' + added_track_id, { | ||||
| 		const res2 = await axios.put(base + '/api/tracks/' + added_track_id, { | ||||
| 			"id": added_track_id, | ||||
| 			"name": "apitrack", | ||||
| 			"distance": 5100 | ||||
| @@ -89,7 +90,7 @@ describe('adding + getting + updating', () => { | ||||
| 		expect(res2.headers['content-type']).toContain("application/json") | ||||
| 	}) | ||||
| 	it('get should return 200', async () => { | ||||
| 		const res3 = await axios.get('http://localhost:4010/api/tracks'); | ||||
| 		const res3 = await axios.get(base + '/api/tracks'); | ||||
| 		expect(res3.status).toEqual(200); | ||||
| 		expect(res3.headers['content-type']).toContain("application/json") | ||||
| 		let added_track2 = res3.data[res3.data.length - 1] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user