Switched tests over to the new id-only schema
All checks were successful
continuous-integration/drone/pr Build is passing

ref #90
This commit is contained in:
Nicolai Ort 2021-01-15 18:50:35 +01:00
parent 420e9c4662
commit d88fb18319
3 changed files with 20 additions and 15 deletions

View File

@ -34,7 +34,7 @@ describe('POST /api/donors with errors', () => {
"firstname": "first", "firstname": "first",
"middlename": "middle", "middlename": "middle",
"lastname": "last", "lastname": "last",
"address": 0 "address": 99999999999999999999999999
}, axios_config); }, axios_config);
expect(res2.status).toEqual(404); expect(res2.status).toEqual(404);
expect(res2.headers['content-type']).toContain("application/json") expect(res2.headers['content-type']).toContain("application/json")

View File

@ -43,7 +43,7 @@ describe('adding + updating name', () => {
"id": added_team_id, "id": added_team_id,
"name": "testlelele", "name": "testlelele",
"contact": null, "contact": null,
"parentGroup": added_org "parentGroup": added_org.id
}, axios_config); }, 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")
@ -79,6 +79,7 @@ describe('adding + try updating id (should return 406)', () => {
}); });
it('update team', async () => { it('update team', async () => {
added_team.id = added_team.id + 1; added_team.id = added_team.id + 1;
added_team.parentGroup = added_team.parentGroup.id;
const res3 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config); const res3 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config);
expect(res3.status).toEqual(406); expect(res3.status).toEqual(406);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
@ -117,7 +118,7 @@ describe('add+update parent org (valid)', () => {
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
}); });
it('update team', async () => { it('update team', async () => {
added_team.parentGroup = added_org2; added_team.parentGroup = added_org2.id;
const res4 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config); const res4 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config);
let updated_team = res4.data; let updated_team = res4.data;
expect(res4.status).toEqual(200); expect(res4.status).toEqual(200);
@ -125,6 +126,6 @@ describe('add+update parent org (valid)', () => {
delete added_org2.address; delete added_org2.address;
delete added_org2.contact; delete added_org2.contact;
delete added_org2.teams; delete added_org2.teams;
expect(updated_team).toEqual(added_team) expect(updated_team.parentGroup).toEqual(added_org2)
}); });
}); });

View File

@ -15,15 +15,14 @@ beforeAll(async () => {
}); });
describe('Update runner name after adding', () => { describe('Update runner name after adding', () => {
let added_org_id; let added_org;
let added_runner; let added_runner;
let updated_runner; let updated_runner;
it('creating a new org with just a name should return 200', async () => { it('creating a new org with just a name should return 200', async () => {
const res1 = await axios.post(base + '/api/organisations', { const res1 = await axios.post(base + '/api/organisations', {
"name": "test123" "name": "test123"
}, axios_config); }, axios_config);
let added_org = res1.data added_org = res1.data
added_org_id = added_org.id;
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")
}); });
@ -31,7 +30,7 @@ describe('Update runner name after adding', () => {
const res2 = await axios.post(base + '/api/runners', { const res2 = await axios.post(base + '/api/runners', {
"firstname": "first", "firstname": "first",
"lastname": "last", "lastname": "last",
"group": added_org_id "group": added_org.id
}, axios_config); }, axios_config);
added_runner = res2.data; added_runner = res2.data;
expect(res2.status).toEqual(200); expect(res2.status).toEqual(200);
@ -40,10 +39,15 @@ describe('Update runner name after adding', () => {
it('valid update should return 200', async () => { it('valid update should return 200', async () => {
let runnercopy = added_runner let runnercopy = added_runner
runnercopy.firstname = "second" runnercopy.firstname = "second"
runnercopy.group = added_runner.group.id;
const res3 = await axios.put(base + '/api/runners/' + added_runner.id, runnercopy, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner.id, runnercopy, 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")
updated_runner = res3.data updated_runner = res3.data;
delete added_org.address;
delete added_org.contact;
delete added_org.teams;
runnercopy.group = added_org;
expect(updated_runner).toEqual(runnercopy); expect(updated_runner).toEqual(runnercopy);
}); });
}); });
@ -83,13 +87,13 @@ describe('Update runner group after adding', () => {
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")
}); });
it('valid update should return 200', async () => { it('valid group update should return 200', async () => {
added_runner.group = added_org_2; added_runner.group = added_org_2.id;
const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, 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")
updated_runner = res3.data updated_runner = res3.data
expect(updated_runner).toEqual(added_runner); expect(updated_runner.group).toEqual(added_org_2);
}); });
}); });
// --------------- // ---------------
@ -119,6 +123,7 @@ describe('Update runner id after adding(should fail)', () => {
}); });
it('invalid update should return 406', async () => { it('invalid update should return 406', async () => {
added_runner.id++; added_runner.id++;
added_runner.group = added_runner.group.id;
const res3 = await axios.put(base + '/api/runners/' + added_runner_id, added_runner, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner_id, added_runner, axios_config);
expect(res3.status).toEqual(406); expect(res3.status).toEqual(406);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
@ -146,9 +151,8 @@ describe('Update runner group with invalid group after adding', () => {
expect(res2.status).toEqual(200); expect(res2.status).toEqual(200);
expect(res2.headers['content-type']).toContain("application/json") expect(res2.headers['content-type']).toContain("application/json")
}); });
it('invalid update should return 404', async () => { it('invalid group update should return 404', async () => {
added_org.id = 0; added_runner.group = 99999999999999999;
added_runner.group = added_org;
const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, axios_config);
expect(res3.status).toEqual(404); expect(res3.status).toEqual(404);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")