parent
599296c4e3
commit
82a0e194cb
@ -72,30 +72,26 @@ describe('adding + getting tracks', () => {
|
|||||||
});
|
});
|
||||||
// ---------------
|
// ---------------
|
||||||
describe('adding + getting + updating', () => {
|
describe('adding + getting + updating', () => {
|
||||||
let added_track_id
|
let added_track;
|
||||||
it('correct distance input should return 200', async () => {
|
it('correct distance input should return 200', async () => {
|
||||||
const res = await axios.post(base + '/api/tracks', {
|
const res = await axios.post(base + '/api/tracks', {
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"distance": 1500
|
"distance": 1500
|
||||||
}, axios_config);
|
}, axios_config);
|
||||||
expect(res.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(res.headers['content-type']).toContain("application/json")
|
expect(res.headers['content-type']).toContain("application/json");
|
||||||
|
added_track = res.data;
|
||||||
});
|
});
|
||||||
it('get should return 200', async () => {
|
it('get should return 200', async () => {
|
||||||
const res1 = await axios.get(base + '/api/tracks', axios_config);
|
const res1 = await axios.get(base + '/api/tracks/' + added_track.id, axios_config);
|
||||||
expect(res1.status).toEqual(200);
|
expect(res1.status).toEqual(200);
|
||||||
expect(res1.headers['content-type']).toContain("application/json")
|
expect(res1.headers['content-type']).toContain("application/json")
|
||||||
let added_track = res1.data[res1.data.length - 1]
|
const compareTrack = res1.data;
|
||||||
added_track_id = added_track.id
|
expect(compareTrack).toEqual(added_track)
|
||||||
delete added_track.id
|
|
||||||
expect(added_track).toEqual({
|
|
||||||
"name": "string",
|
|
||||||
"distance": 1500
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
it('get should return 200', async () => {
|
it('get should return 200', async () => {
|
||||||
const res2 = await axios.put(base + '/api/tracks/' + added_track_id, {
|
const res2 = await axios.put(base + '/api/tracks/' + added_track.id, {
|
||||||
"id": added_track_id,
|
"id": added_track.id,
|
||||||
"name": "apitrack",
|
"name": "apitrack",
|
||||||
"distance": 5100
|
"distance": 5100
|
||||||
}, axios_config);
|
}, axios_config);
|
||||||
@ -103,10 +99,10 @@ describe('adding + getting + updating', () => {
|
|||||||
expect(res2.headers['content-type']).toContain("application/json")
|
expect(res2.headers['content-type']).toContain("application/json")
|
||||||
})
|
})
|
||||||
it('get should return 200', async () => {
|
it('get should return 200', async () => {
|
||||||
const res3 = await axios.get(base + '/api/tracks', axios_config);
|
const res3 = await axios.get(base + '/api/tracks/' + added_track.id, axios_config);
|
||||||
expect(res3.status).toEqual(200);
|
expect(res3.status).toEqual(200);
|
||||||
expect(res3.headers['content-type']).toContain("application/json")
|
expect(res3.headers['content-type']).toContain("application/json")
|
||||||
let added_track2 = res3.data[res3.data.length - 1]
|
let added_track2 = res3.data;
|
||||||
delete added_track2.id
|
delete added_track2.id
|
||||||
expect(added_track2).toEqual({
|
expect(added_track2).toEqual({
|
||||||
"name": "apitrack",
|
"name": "apitrack",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user