feature/17-automated_tests #21

Merged
niggl merged 56 commits from feature/17-automated_tests into dev 2020-12-10 19:36:08 +00:00
Showing only changes of commit 07e03ff04e - Show all commits

36
src/tests/tracks.spec.ts Normal file
View File

@ -0,0 +1,36 @@
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 });
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', {
"name": "string",
"distance": 400
}, { validateStatus: undefined });
expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json")
});
});
// ---------------
describe('POST /api/tracks', () => {
it('illegal distance input should return 400', async () => {
const res = await axios.post('http://localhost:4010/api/tracks', {
"name": "string",
"distance": -1
}, { validateStatus: undefined });
expect(res.status).toEqual(400);
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', {
"name": "string",
"distance": 400
}, { validateStatus: undefined });
expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json")
});
});