Adjusted tests for the new responseType parameter (part 1)

ref #132
This commit is contained in:
Nicolai Ort 2021-01-29 18:46:15 +01:00
parent 2a87819486
commit bcc15e4286
18 changed files with 113 additions and 62 deletions

View File

@ -34,7 +34,8 @@ describe('POST /api/cards successfully (without runner)', () => {
delete res.data.code;
expect(res.data).toEqual({
"runner": null,
"enabled": true
"enabled": true,
"responseType": "RUNNERCARD"
});
});
it('creating a disabled card should return 200', async () => {
@ -47,7 +48,8 @@ describe('POST /api/cards successfully (without runner)', () => {
delete res.data.code;
expect(res.data).toEqual({
"runner": null,
"enabled": false
"enabled": false,
"responseType": "RUNNERCARD"
});
});
it('creating a enabled card should return 200', async () => {
@ -60,7 +62,8 @@ describe('POST /api/cards successfully (without runner)', () => {
delete res.data.code;
expect(res.data).toEqual({
"runner": null,
"enabled": true
"enabled": true,
"responseType": "RUNNERCARD"
});
});
});
@ -97,7 +100,8 @@ describe('POST /api/cards successfully (with runner)', () => {
delete res.data.code;
expect(res.data).toEqual({
"runner": added_runner,
"enabled": true
"enabled": true,
"responseType": "RUNNERCARD"
});
});
it('creating a card with runner (no optional params) should return 200', async () => {
@ -110,7 +114,8 @@ describe('POST /api/cards successfully (with runner)', () => {
delete res.data.code;
expect(res.data).toEqual({
"runner": added_runner,
"enabled": true
"enabled": true,
"responseType": "RUNNERCARD"
});
});
it('creating a enabled card with runner should return 200', async () => {
@ -124,7 +129,8 @@ describe('POST /api/cards successfully (with runner)', () => {
delete res.data.code;
expect(res.data).toEqual({
"runner": added_runner,
"enabled": true
"enabled": true,
"responseType": "RUNNERCARD"
});
});
it('creating a disabled card with runner should return 200', async () => {
@ -138,7 +144,8 @@ describe('POST /api/cards successfully (with runner)', () => {
delete res.data.code;
expect(res.data).toEqual({
"runner": added_runner,
"enabled": false
"enabled": false,
"responseType": "RUNNERCARD"
});
});
});

View File

@ -96,7 +96,8 @@ describe('adding + updating card.runner successfully', () => {
"id": added_card.id,
"runner": added_runner,
"enabled": true,
"code": added_card.code
"code": added_card.code,
"responseType": "RUNNERCARD"
});
});
it('valid runner update (change runner) should return 200', async () => {
@ -110,7 +111,8 @@ describe('adding + updating card.runner successfully', () => {
"id": added_card.id,
"runner": added_runner2,
"enabled": true,
"code": added_card.code
"code": added_card.code,
"responseType": "RUNNERCARD"
});
});
});
@ -142,7 +144,8 @@ describe('adding + updating other values successfully', () => {
"id": added_card.id,
"runner": null,
"enabled": false,
"code": added_card.code
"code": added_card.code,
"responseType": "RUNNERCARD"
});
});
it('valid enable update should return 200', async () => {
@ -156,7 +159,8 @@ describe('adding + updating other values successfully', () => {
"id": added_card.id,
"runner": null,
"enabled": true,
"code": added_card.code
"code": added_card.code,
"responseType": "RUNNERCARD"
});
});
});

View File

@ -149,7 +149,8 @@ describe('POST /api/contacts working (with group)', () => {
"city": null,
"country": null
},
"groups": [added_org]
"groups": [added_org],
"responseType": "GROUPCONTACT"
});
});
it('creating a new contact with a valid team should return 200', async () => {
@ -174,7 +175,8 @@ describe('POST /api/contacts working (with group)', () => {
"city": null,
"country": null
},
"groups": [added_team]
"groups": [added_team],
"responseType": "GROUPCONTACT"
});
});
it('creating a new contact with a valid org and team should return 200', async () => {
@ -200,7 +202,8 @@ describe('POST /api/contacts working (with group)', () => {
"city": null,
"country": null
},
"groups": [added_org, added_team]
"groups": [added_org, added_team],
"responseType": "GROUPCONTACT"
});
});
it('checking if the added team\'s contact is the new contact should return 200', async () => {

View File

@ -101,7 +101,8 @@ describe('Update contact group after adding (should work)', () => {
"city": null,
"country": null
},
"groups": [added_org]
"groups": [added_org],
"responseType": "GROUPCONTACT"
});
});
it('valid group update to single team should return 200', async () => {
@ -127,7 +128,8 @@ describe('Update contact group after adding (should work)', () => {
"city": null,
"country": null
},
"groups": [added_team]
"groups": [added_team],
"responseType": "GROUPCONTACT"
});
});
it('valid group update to org and team should return 200', async () => {
@ -153,7 +155,8 @@ describe('Update contact group after adding (should work)', () => {
"city": null,
"country": null
},
"groups": [added_org, added_team]
"groups": [added_org, added_team],
"responseType": "GROUPCONTACT"
});
});
it('valid group update to none should return 200', async () => {
@ -179,7 +182,8 @@ describe('Update contact group after adding (should work)', () => {
"city": null,
"country": null
},
"groups": []
"groups": [],
"responseType": "GROUPCONTACT"
});
});
});
@ -220,7 +224,8 @@ describe('Update contact group invalid after adding (should fail)', () => {
"city": null,
"country": null
},
"groups": [added_org]
"groups": [added_org],
"responseType": "GROUPCONTACT"
});
});
it('invalid group update to single team should return 404', async () => {

View File

@ -179,7 +179,8 @@ describe('POST /api/donations/fixed successfully', () => {
expect(res.headers['content-type']).toContain("application/json");
expect(res.data).toEqual({
"donor": added_donor,
"amount": 1000
"amount": 1000,
"responseType": "DONATION"
});
});
});
@ -230,7 +231,8 @@ describe('POST /api/donations/distance successfully', () => {
"donor": added_donor,
"amountPerDistance": 100,
"runner": added_runner,
"amount": 0
"amount": 0,
"responseType": "DISTANCEDONATION"
})
});
});

View File

@ -55,7 +55,6 @@ describe('adding + getting from all orgs', () => {
delete added_org.id
expect(added_org).toEqual({
"name": "test123",
"contact": null,
"address": {
"address1": null,
"address2": null,
@ -64,7 +63,8 @@ describe('adding + getting from all orgs', () => {
"postalcode": null,
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
})
});
});
@ -89,7 +89,6 @@ describe('adding + getting explicitly', () => {
delete added_org2.id
expect(added_org2).toEqual({
"name": "test123",
"contact": null,
"address": {
"address1": null,
"address2": null,
@ -98,7 +97,8 @@ describe('adding + getting explicitly', () => {
"postalcode": null,
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
})
});
});

View File

@ -43,7 +43,6 @@ describe('adding + deletion (successfull)', () => {
delete added_org2.id
expect(added_org2).toEqual({
"name": "test123",
"contact": null,
"address": {
"address1": null,
"address2": null,
@ -52,7 +51,8 @@ describe('adding + deletion (successfull)', () => {
"postalcode": null,
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
it('check if org really was deleted', async () => {
@ -127,7 +127,6 @@ describe('adding + deletion with teams still existing (with force)', () => {
delete added_org2.teams;
expect(added_org2).toEqual({
"name": "test123",
"contact": null,
"address": {
"address1": null,
"address2": null,
@ -136,6 +135,7 @@ describe('adding + deletion with teams still existing (with force)', () => {
"postalcode": null,
},
"registrationEnabled": false,
"responseType": "RUNNERORGANIZATION"
});
});
it('check if org really was deleted', async () => {

View File

@ -41,7 +41,6 @@ describe('adding + updating name', () => {
delete added_org2.id
expect(added_org2).toEqual({
"name": "testlelele",
"contact": null,
"address": {
"address1": null,
"address2": null,
@ -50,7 +49,8 @@ describe('adding + updating name', () => {
"postalcode": null,
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
})
});
});
@ -109,7 +109,6 @@ describe('adding + updateing address valid)', () => {
expect(res.data).toEqual({
"id": added_org_id,
"name": "testlelele",
"contact": null,
"address": {
"address1": "Test1",
"address2": null,
@ -118,7 +117,8 @@ describe('adding + updateing address valid)', () => {
"postalcode": "90174"
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
it('updateing address\'s first line should return 200', async () => {
@ -139,7 +139,6 @@ describe('adding + updateing address valid)', () => {
expect(res.data).toEqual({
"id": added_org_id,
"name": "testlelele",
"contact": null,
"address": {
"address1": "Test2",
"address2": null,
@ -148,7 +147,8 @@ describe('adding + updateing address valid)', () => {
"postalcode": "90174"
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
it('updateing address\'s second line should return 200', async () => {
@ -169,7 +169,6 @@ describe('adding + updateing address valid)', () => {
expect(res.data).toEqual({
"id": added_org_id,
"name": "testlelele",
"contact": null,
"address": {
"address1": "Test2",
"address2": "Test3",
@ -178,7 +177,8 @@ describe('adding + updateing address valid)', () => {
"postalcode": "90174"
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
it('updateing address\'s city should return 200', async () => {
@ -199,7 +199,6 @@ describe('adding + updateing address valid)', () => {
expect(res.data).toEqual({
"id": added_org_id,
"name": "testlelele",
"contact": null,
"address": {
"address1": "Test2",
"address2": "Test3",
@ -208,7 +207,8 @@ describe('adding + updateing address valid)', () => {
"postalcode": "90174"
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
it('updateing address\'s country should return 200', async () => {
@ -238,7 +238,8 @@ describe('adding + updateing address valid)', () => {
"postalcode": "90174"
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
it('updateing address\'s postal code should return 200', async () => {
@ -259,7 +260,6 @@ describe('adding + updateing address valid)', () => {
expect(res.data).toEqual({
"id": added_org_id,
"name": "testlelele",
"contact": null,
"address": {
"address1": "Test2",
"address2": "Test3",
@ -268,7 +268,8 @@ describe('adding + updateing address valid)', () => {
"postalcode": "91065"
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
it('removing org\'s address should return 200', async () => {
@ -282,7 +283,6 @@ describe('adding + updateing address valid)', () => {
expect(res.data).toEqual({
"id": added_org_id,
"name": "testlelele",
"contact": null,
"address": {
"address1": null,
"address2": null,
@ -291,7 +291,8 @@ describe('adding + updateing address valid)', () => {
"postalcode": null
},
"registrationEnabled": false,
"teams": []
"teams": [],
"responseType": "RUNNERORGANIZATION"
});
});
});

View File

@ -48,7 +48,7 @@ describe('adding org', () => {
delete deleted_team.parentGroup;
expect(deleted_team).toEqual({
"name": "test123",
"contact": null
"responseType": "RUNNERTEAM"
});
});
it('check if team really was deleted', async () => {

View File

@ -17,6 +17,7 @@ beforeAll(async () => {
describe('GET /api/runners', () => {
it('basic get should return 200', async () => {
const res = await axios.get(base + '/api/runners', axios_config);
console.log(res.data)
expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json")
});

View File

@ -131,6 +131,7 @@ describe('GET /api/teams/:id/runners after adding', () => {
});
it('check if scans was added via the orgs/runners endpoint.', async () => {
const res = await axios.get(base + '/api/teams/' + added_team.id + "/runners", axios_config);
console.log(res.data);
expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json");
expect(res.data).toContainEqual(added_runner);

View File

@ -98,10 +98,12 @@ describe('POST /api/scans successfully', () => {
expect(res.headers['content-type']).toContain("application/json");
delete res.data.id;
delete res.data.runner.distance;
delete res.data.runner.group;
expect(res.data).toEqual({
"runner": added_runner,
"distance": 200,
"valid": true
"valid": true,
"responseType": "SCAN"
});
});
it('creating a valid scan should return 200', async () => {
@ -114,10 +116,12 @@ describe('POST /api/scans successfully', () => {
expect(res.headers['content-type']).toContain("application/json");
delete res.data.id;
delete res.data.runner.distance;
delete res.data.runner.group;
expect(res.data).toEqual({
"runner": added_runner,
"distance": 200,
"valid": true
"valid": true,
"responseType": "SCAN"
});
});
it('creating a invalid scan should return 200', async () => {
@ -130,10 +134,12 @@ describe('POST /api/scans successfully', () => {
expect(res.headers['content-type']).toContain("application/json");
delete res.data.id;
delete res.data.runner.distance;
delete res.data.runner.group;
expect(res.data).toEqual({
"runner": added_runner,
"distance": 200,
"valid": false
"valid": false,
"responseType": "SCAN"
});
});
});
@ -192,10 +198,12 @@ describe('POST /api/scans successfully via scan station', () => {
expect(res.headers['content-type']).toContain("application/json");
delete res.data.id;
delete res.data.runner.distance;
delete res.data.runner.group;
expect(res.data).toEqual({
"runner": added_runner,
"distance": 200,
"valid": true
"valid": true,
"responseType": "SCAN",
});
});
it('creating a valid scan should return 200', async () => {
@ -211,10 +219,12 @@ describe('POST /api/scans successfully via scan station', () => {
expect(res.headers['content-type']).toContain("application/json");
delete res.data.id;
delete res.data.runner.distance;
delete res.data.runner.group;
expect(res.data).toEqual({
"runner": added_runner,
"distance": 200,
"valid": true
"valid": true,
"responseType": "SCAN"
});
});
it('creating a invalid scan should return 200', async () => {
@ -230,10 +240,12 @@ describe('POST /api/scans successfully via scan station', () => {
expect(res.headers['content-type']).toContain("application/json");
delete res.data.id;
delete res.data.runner.distance;
delete res.data.runner.group;
expect(res.data).toEqual({
"runner": added_runner,
"distance": 200,
"valid": false
"valid": false,
"responseType": "SCAN",
});
});
});

View File

@ -72,6 +72,7 @@ describe('adding + getting scans', () => {
expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json");
added_scan.runner.distance = 0;
added_scan.runner.group = added_org;
expect(res.data).toContainEqual(added_scan);
});
});

View File

@ -123,12 +123,13 @@ describe('adding + updating successfilly', () => {
expect(res2.status).toEqual(200);
expect(res2.headers['content-type']).toContain("application/json")
delete res2.data.runner.distance;
delete res2.data.runner.group;
expect(res2.data).toEqual({
"id": added_scan.id,
"runner": added_runner,
"distance": 100,
"valid": true
"valid": true,
"responseType": "SCAN"
});
});
it('valid valid update should return 200', async () => {
@ -141,11 +142,13 @@ describe('adding + updating successfilly', () => {
expect(res2.status).toEqual(200);
expect(res2.headers['content-type']).toContain("application/json");
delete res2.data.runner.distance;
delete res2.data.runner.group;
expect(res2.data).toEqual({
"id": added_scan.id,
"runner": added_runner,
"distance": 100,
"valid": false
"valid": false,
"responseType": "SCAN"
});
});
it('creating a new runner with only needed params should return 200', async () => {
@ -169,11 +172,13 @@ describe('adding + updating successfilly', () => {
expect(res2.status).toEqual(200);
expect(res2.headers['content-type']).toContain("application/json");
delete res2.data.runner.distance;
delete res2.data.runner.group;
expect(res2.data).toEqual({
"id": added_scan.id,
"runner": added_runner2,
"distance": added_scan.distance,
"valid": added_scan.valid
"valid": added_scan.valid,
"responseType": "SCAN"
});
});
});

View File

@ -56,7 +56,8 @@ describe('POST /api/stations successfully', () => {
expect(res.data).toEqual({
"track": added_track,
"description": null,
"enabled": true
"enabled": true,
"responseType": "SCANSTATION"
});
});
it('creating a station with all parameters (optional set to true/empty) should return 200', async () => {
@ -73,7 +74,8 @@ describe('POST /api/stations successfully', () => {
expect(res.data).toEqual({
"track": added_track,
"description": null,
"enabled": true
"enabled": true,
"responseType": "SCANSTATION"
});
});
it('creating a disabled station with all parameters (optional set to true/empty) should return 200', async () => {
@ -90,7 +92,8 @@ describe('POST /api/stations successfully', () => {
expect(res.data).toEqual({
"track": added_track,
"description": null,
"enabled": false
"enabled": false,
"responseType": "SCANSTATION"
});
});
it('creating a station with all parameters (optional set) should return 200', async () => {
@ -107,7 +110,8 @@ describe('POST /api/stations successfully', () => {
expect(res.data).toEqual({
"track": added_track,
"description": "test station for testing",
"enabled": true
"enabled": true,
"responseType": "SCANSTATION"
});
});
});

View File

@ -54,7 +54,8 @@ describe('POST /api/tracks successfully', () => {
expect(res.data).toEqual({
"name": "testtrack",
"distance": 200,
"minimumLapTime": null
"minimumLapTime": null,
"responseType": "TRACK"
})
});
it('creating a track with all parameters (optional set to null) should return 200', async () => {
@ -69,7 +70,8 @@ describe('POST /api/tracks successfully', () => {
expect(res.data).toEqual({
"name": "testtrack",
"distance": 200,
"minimumLapTime": null
"minimumLapTime": null,
"responseType": "TRACK"
})
});
it('creating a track with all parameters should return 200', async () => {
@ -84,7 +86,8 @@ describe('POST /api/tracks successfully', () => {
expect(res.data).toEqual({
"name": "testtrack",
"distance": 200,
"minimumLapTime": 123
"minimumLapTime": 123,
"responseType": "TRACK"
})
});
});

View File

@ -35,7 +35,8 @@ describe('DETELE track', () => {
expect(res2.data).toEqual({
"name": "testtrack",
"distance": 200,
"minimumLapTime": null
"minimumLapTime": null,
"responseType": "TRACK"
});
});
it('check if track really was deleted', async () => {

View File

@ -242,6 +242,7 @@ describe('POST /api/scans successfully via scan station', () => {
headers: { "authorization": "Bearer " + added_station.key },
validateStatus: undefined
});
console.log(res.data)
expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json");
expect(res.data.valid).toEqual(false);