From 904f2c7f1103ecc4ddca194e9604e75d248e0e2f Mon Sep 17 00:00:00 2001 From: Nwankwo Samuel Date: Tue, 11 Oct 2022 15:55:08 +0100 Subject: [PATCH 1/2] add multiply, subtract --- test/integration/app.test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/integration/app.test.js b/test/integration/app.test.js index 506e859..3d481de 100644 --- a/test/integration/app.test.js +++ b/test/integration/app.test.js @@ -14,4 +14,28 @@ describe("Calculate", () => { expect(response.status).toBe(200) expect(response.body).toBe(JSON.stringify({ result: 30 })) }) + + it('POST /calculate: action: multiply', async () => { + const response = await supertest(server).post('/calculate').send({ + action: 'multiply', + num1: 20, + num2: 10 + }) + + // console.log({response}) + expect(response.status).toBe(200) + expect(response.text).toBe(JSON.stringify({ result: 200 })) + }) + + it('POST /calculate: action: subtract', async () => { + const response = await supertest(server).post('/calculate').send({ + action: 'subtract', + num1: 20, + num2: 10 + }) + + // console.log({response}) + expect(response.status).toBe(200) + expect(response.text).toBe(JSON.stringify({ result: 10 })) + }) }) \ No newline at end of file From e073684fb61bb47a2fd4f2faee46e18c54f78acb Mon Sep 17 00:00:00 2001 From: Nwankwo Samuel Date: Tue, 11 Oct 2022 15:58:41 +0100 Subject: [PATCH 2/2] added divide --- test/integration/app.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/integration/app.test.js b/test/integration/app.test.js index 3d481de..67f6552 100644 --- a/test/integration/app.test.js +++ b/test/integration/app.test.js @@ -26,7 +26,7 @@ describe("Calculate", () => { expect(response.status).toBe(200) expect(response.text).toBe(JSON.stringify({ result: 200 })) }) - + it('POST /calculate: action: subtract', async () => { const response = await supertest(server).post('/calculate').send({ action: 'subtract', @@ -38,4 +38,16 @@ describe("Calculate", () => { expect(response.status).toBe(200) expect(response.text).toBe(JSON.stringify({ result: 10 })) }) + + it('POST /calculate: action: divide', async () => { + const response = await supertest(server).post('/calculate').send({ + action: 'divide', + num1: 20, + num2: 10 + }) + + // console.log({response}) + expect(response.status).toBe(200) + expect(response.text).toBe(JSON.stringify({ result: 2 })) + }) }) \ No newline at end of file