From 4e3b038dec481bdfef53c4cd136120b19d1b462e Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 9 Dec 2020 17:56:37 +0100 Subject: [PATCH] Added bad test to the put --- src/tests/runnerGroups/org_add+update.spec.ts | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tests/runnerGroups/org_add+update.spec.ts b/src/tests/runnerGroups/org_add+update.spec.ts index 0cdcdc9..fa2a349 100644 --- a/src/tests/runnerGroups/org_add+update.spec.ts +++ b/src/tests/runnerGroups/org_add+update.spec.ts @@ -16,13 +16,12 @@ describe('adding + updating name', () => { expect(res1.status).toEqual(200); expect(res1.headers['content-type']).toContain("application/json") }); - it('check if org was added', async () => { + it('update org', async () => { const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { "id": added_org_id, "name": "testlelele", "contact": null, "address": null, - "teams": [] }); expect(res2.status).toEqual(200); expect(res2.headers['content-type']).toContain("application/json") @@ -37,4 +36,30 @@ describe('adding + updating name', () => { }) }); }); +}); +// --------------- +describe('adding + try updating id (should return 406)', () => { + let added_org_id + let added_org + describe('adding org', () => { + it('creating a new org with just a name should return 200', async () => { + const res1 = await axios.post(base + '/api/organisations', { + "name": "test123" + }); + added_org = res1.data + added_org_id = added_org.id; + expect(res1.status).toEqual(200); + expect(res1.headers['content-type']).toContain("application/json") + }); + it('update org', async () => { + const res2 = await axios.put(base + '/api/organisations/' + added_org_id, { + "id": added_org_id + 1, + "name": "testlelele", + "contact": null, + "address": null, + }, { validateStatus: undefined }); + expect(res2.status).toEqual(406); + expect(res2.headers['content-type']).toContain("application/json") + }); + }); }); \ No newline at end of file