Added donation add validtests

ref #66
This commit is contained in:
Nicolai Ort 2021-01-12 20:15:51 +01:00
parent badff85e28
commit e3e570e664

View File

@ -157,175 +157,80 @@ describe('POST /api/donations/distance illegally', () => {
expect(res.headers['content-type']).toContain("application/json") expect(res.headers['content-type']).toContain("application/json")
}); });
}); });
// // --------------- // ---------------
// describe('POST /api/scans successfully', () => { describe('POST /api/donations/fixed successfully', () => {
// let added_org; let added_donor;
// let added_runner; it('creating a new donor with only needed params should return 200', async () => {
// it('creating a new org with just a name should return 200', async () => { const res = await axios.post(base + '/api/donors', {
// const res1 = await axios.post(base + '/api/organisations', { "firstname": "first",
// "name": "test123" "lastname": "last"
// }, axios_config); }, axios_config);
// added_org = res1.data added_donor = res.data
// expect(res1.status).toEqual(200); expect(res.status).toEqual(200);
// expect(res1.headers['content-type']).toContain("application/json") expect(res.headers['content-type']).toContain("application/json")
// }); });
// it('creating a new runner with only needed params should return 200', async () => { it('creating a new fixed donation should return 200', async () => {
// const res2 = await axios.post(base + '/api/runners', { const res = await axios.post(base + '/api/donations/fixed', {
// "firstname": "first", "donor": added_donor.id,
// "lastname": "last", "amount": 1000
// "group": added_org.id }, axios_config);
// }, axios_config); delete res.data.id;
// delete res2.data.group; expect(res.status).toEqual(200);
// delete res2.data.distance; expect(res.headers['content-type']).toContain("application/json");
// added_runner = res2.data; expect(res.data).toEqual({
// expect(res2.status).toEqual(200); "donor": added_donor,
// expect(res2.headers['content-type']).toContain("application/json") "amount": 1000
// }); });
// it('creating a scan with the minimum amount of parameters should return 200', async () => { });
// const res = await axios.post(base + '/api/scans', { });
// "runner": added_runner.id, // ---------------
// "distance": 200 describe('POST /api/donations/distance successfully', () => {
// }, axios_config); let added_donor;
// expect(res.status).toEqual(200); let added_org;
// expect(res.headers['content-type']).toContain("application/json"); let added_runner;
// delete res.data.id; let added_donation;
// delete res.data.runner.distance; it('creating a new donor with only needed params should return 200', async () => {
// expect(res.data).toEqual({ const res = await axios.post(base + '/api/donors', {
// "runner": added_runner, "firstname": "first",
// "distance": 200, "lastname": "last"
// "valid": true }, axios_config);
// }); added_donor = res.data
// }); expect(res.status).toEqual(200);
// it('creating a valid scan should return 200', async () => { expect(res.headers['content-type']).toContain("application/json")
// const res = await axios.post(base + '/api/scans', { });
// "runner": added_runner.id, it('creating a new org with just a name should return 200', async () => {
// "distance": 200, const res = await axios.post(base + '/api/organisations', {
// "valid": true "name": "test123"
// }, axios_config); }, axios_config);
// expect(res.status).toEqual(200); added_org = res.data
// expect(res.headers['content-type']).toContain("application/json"); expect(res.status).toEqual(200);
// delete res.data.id; expect(res.headers['content-type']).toContain("application/json")
// delete res.data.runner.distance; });
// expect(res.data).toEqual({ it('creating a new runner with only needed params should return 200', async () => {
// "runner": added_runner, const res = await axios.post(base + '/api/runners', {
// "distance": 200, "firstname": "first",
// "valid": true "lastname": "last",
// }); "group": added_org.id
// }); }, axios_config);
// it('creating a invalid scan should return 200', async () => { delete res.data.group;
// const res = await axios.post(base + '/api/scans', { added_runner = res.data;
// "runner": added_runner.id, expect(res.status).toEqual(200);
// "distance": 200, expect(res.headers['content-type']).toContain("application/json")
// "valid": false });
// }, axios_config); it('creating a new fixed donation should return 200', async () => {
// expect(res.status).toEqual(200); const res = await axios.post(base + '/api/donations/distance', {
// expect(res.headers['content-type']).toContain("application/json"); "runner": added_runner.id,
// delete res.data.id; "amountPerDistance": 100,
// delete res.data.runner.distance; "donor": added_donor.id
// expect(res.data).toEqual({ }, axios_config);
// "runner": added_runner, delete res.data.id;
// "distance": 200, expect(res.status).toEqual(200);
// "valid": false expect(res.headers['content-type']).toContain("application/json");
// }); expect(res.data).toEqual({
// }); "donor": added_donor,
// }); "amountPerDistance": 100,
// // --------------- "runner": added_runner,
// describe('POST /api/scans successfully via scan station', () => { "amount": 0
// let added_org; })
// let added_runner; });
// let added_track; });
// let added_station;
// it('creating a new org with just a name should return 200', async () => {
// const res1 = await axios.post(base + '/api/organisations', {
// "name": "test123"
// }, axios_config);
// added_org = res1.data
// expect(res1.status).toEqual(200);
// expect(res1.headers['content-type']).toContain("application/json")
// });
// it('creating a new runner with only needed params should return 200', async () => {
// const res2 = await axios.post(base + '/api/runners', {
// "firstname": "first",
// "lastname": "last",
// "group": added_org.id
// }, axios_config);
// delete res2.data.group;
// delete res2.data.distance;
// added_runner = res2.data;
// expect(res2.status).toEqual(200);
// expect(res2.headers['content-type']).toContain("application/json")
// });
// it('creating a track with the minimum amount of parameters should return 200', async () => {
// const res = await axios.post(base + '/api/tracks', {
// "name": "testtrack",
// "distance": 200,
// }, axios_config);
// added_track = res.data;
// expect(res.status).toEqual(200);
// expect(res.headers['content-type']).toContain("application/json");
// });
// it('creating a station with minimum parameters should return 200', async () => {
// const res = await axios.post(base + '/api/stations', {
// "track": added_track.id
// }, axios_config);
// added_station = res.data;
// expect(res.status).toEqual(200);
// expect(res.headers['content-type']).toContain("application/json");
// });
// it('creating a scan with the minimum amount of parameters should return 200', async () => {
// const res = await axios.post(base + '/api/scans', {
// "runner": added_runner.id,
// "distance": 200
// }, {
// headers: { "authorization": "Bearer " + added_station.key },
// validateStatus: undefined
// });
// expect(res.status).toEqual(200);
// expect(res.headers['content-type']).toContain("application/json");
// delete res.data.id;
// delete res.data.runner.distance;
// expect(res.data).toEqual({
// "runner": added_runner,
// "distance": 200,
// "valid": true
// });
// });
// it('creating a valid scan should return 200', async () => {
// const res = await axios.post(base + '/api/scans', {
// "runner": added_runner.id,
// "distance": 200,
// "valid": true
// }, {
// headers: { "authorization": "Bearer " + added_station.key },
// validateStatus: undefined
// });
// expect(res.status).toEqual(200);
// expect(res.headers['content-type']).toContain("application/json");
// delete res.data.id;
// delete res.data.runner.distance;
// expect(res.data).toEqual({
// "runner": added_runner,
// "distance": 200,
// "valid": true
// });
// });
// it('creating a invalid scan should return 200', async () => {
// const res = await axios.post(base + '/api/scans', {
// "runner": added_runner.id,
// "distance": 200,
// "valid": false
// }, {
// headers: { "authorization": "Bearer " + added_station.key },
// validateStatus: undefined
// });
// expect(res.status).toEqual(200);
// expect(res.headers['content-type']).toContain("application/json");
// delete res.data.id;
// delete res.data.runner.distance;
// expect(res.data).toEqual({
// "runner": added_runner,
// "distance": 200,
// "valid": false
// });
// });
// });