From 4d40225a4491e8eb3f41ef0fd558a599f63729be Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Sat, 16 Jan 2021 20:26:58 +0100 Subject: [PATCH] Added first address update tests ref #105 --- src/tests/runnerOrgs/org_update.spec.ts | 101 ++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/src/tests/runnerOrgs/org_update.spec.ts b/src/tests/runnerOrgs/org_update.spec.ts index 3db1254..9fa8f8d 100644 --- a/src/tests/runnerOrgs/org_update.spec.ts +++ b/src/tests/runnerOrgs/org_update.spec.ts @@ -76,4 +76,105 @@ describe('adding + try updating id (should return 406)', () => { expect(res2.status).toEqual(406); expect(res2.headers['content-type']).toContain("application/json") }); +}); +// --------------- +describe('adding + updateing address valid)', () => { + let added_org_id + let added_org + 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 + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('adding address to org should return 200', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": { + "address1": "Test1", + "address2": null, + "city": "TestCity", + "country": "Burkina Faso", + "postalcode": "90174" + } + }, axios_config); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json"); + expect(res2.data).toEqual({ + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": { + "address1": "Test1", + "address2": null, + "city": "TestCity", + "country": "Burkina Faso", + "postalcode": "90174" + }, + "teams": [] + }); + }); + it('updateing address\'s first line should return 200', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": { + "address1": "Test2", + "address2": null, + "city": "TestCity", + "country": "Burkina Faso", + "postalcode": "90174" + } + }, axios_config); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json"); + expect(res2.data).toEqual({ + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": { + "address1": "Test2", + "address2": null, + "city": "TestCity", + "country": "Burkina Faso", + "postalcode": "90174" + }, + "teams": [] + }); + }); + it('updateing address\'s second line should return 200', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": { + "address1": "Test2", + "address2": "Test3", + "city": "TestCity", + "country": "Burkina Faso", + "postalcode": "90174" + } + }, axios_config); + expect(res2.status).toEqual(200); + expect(res2.headers['content-type']).toContain("application/json"); + expect(res2.data).toEqual({ + "id": added_org_id, + "name": "testlelele", + "contact": null, + "address": { + "address1": "Test2", + "address2": "Test3", + "city": "TestCity", + "country": "Burkina Faso", + "postalcode": "90174" + }, + "teams": [] + }); + }); }); \ No newline at end of file