From 5f0b83f5ba679a6113110da92484bfc12cacb2d1 Mon Sep 17 00:00:00 2001 From: berkaydoner Date: Mon, 13 Dec 2021 20:22:43 +0300 Subject: [PATCH] Added a unit test for checkIfNumber helper function --- frontend/src/Tests/createevent.test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/frontend/src/Tests/createevent.test.js b/frontend/src/Tests/createevent.test.js index 9d8674d0..194e3482 100644 --- a/frontend/src/Tests/createevent.test.js +++ b/frontend/src/Tests/createevent.test.js @@ -17,3 +17,28 @@ test("Check if dates are compared correctly. First argument must be before the s expect(checkIfDateIsLater("2021-01-12T13:42:00+03:00","2020-01-12T13:42:00+03:00")).toBe(false) }) +test("Check if integer strings are identified correctly",()=>{ + expect(checkIfNumber(1)).toBe(true) + expect(checkIfNumber(12)).toBe(true) + expect(checkIfNumber(100)).toBe(true) + expect(checkIfNumber(1.0)).toBe(true) + expect(checkIfNumber(1.00001)).toBe(true) + expect(checkIfNumber(0.900000)).toBe(true) + + expect(checkIfNumber("1")).toBe(true) + expect(checkIfNumber("10")).toBe(true) + expect(checkIfNumber("110")).toBe(true) + expect(checkIfNumber("0.9")).toBe(true) + expect(checkIfNumber("1.0")).toBe(true) + expect(checkIfNumber("1.0000001")).toBe(true) + expect(checkIfNumber("12.0 ")).toBe(true) + + + expect(checkIfNumber("11a")).toBe(false) + expect(checkIfNumber("berkay123")).toBe(false) + expect(checkIfNumber("a12.3")).toBe(false) + expect(checkIfNumber("12.3a")).toBe(false) + expect(checkIfNumber("12 3")).toBe(false) + expect(checkIfNumber("11. 34")).toBe(false) + expect(checkIfNumber("a12")).toBe(false) +}) \ No newline at end of file