Compare commits

..

No commits in common. "1748fd4034aa5716cf46729794d881bef4b20760" and "4dd0217c93c5e5c5b8e709d65d0456461c7d86b7" have entirely different histories.

2 changed files with 11 additions and 13 deletions

View File

@ -67,8 +67,7 @@
"dev": "nodemon src/app.ts",
"build": "tsc",
"docs": "typedoc --out docs src",
"test": "jest",
"test:watch": "jest --watchAll"
"test": "jest"
},
"nodemonConfig": {
"ignore": [

View File

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