Skip to content

Commit

Permalink
Added a unit test for date comparison method
Browse files Browse the repository at this point in the history
  • Loading branch information
berkaydoner committed Dec 13, 2021
1 parent e7a34ba commit ea5fc05
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions frontend/src/Tests/createevent.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {checkIfDateIsLater,checkIfNumber} from "../Views/Create Event/CreateEventPage";

test("Check if dates are compared correctly. First argument must be before the second one.",()=>{
expect(checkIfDateIsLater("2014-11-30T23:00:00-08:00","2014-11-30T23:01:00-08:00")).toBe(true)
expect(checkIfDateIsLater("2021-01-12T13:42:00+03:00","2021-01-12T13:41:00+03:00")).toBe(false)

expect(checkIfDateIsLater("2014-11-30T22:00:00-08:00","2014-11-30T23:00:00-08:00")).toBe(true)
expect(checkIfDateIsLater("2021-01-12T15:42:00+03:00","2021-01-12T14:42:00+03:00")).toBe(false)

expect(checkIfDateIsLater("Sat Nov 13 10:45:00 2021","Sat Nov 14 10:45:00 2021")).toBe(true)
expect(checkIfDateIsLater("12/17/1997 07:37:16.00 PST","12/16/1997 07:37:16.00 PST")).toBe(false)

expect(checkIfDateIsLater("2014-11-30T23:00:00-08:00","2014-12-30T23:00:00-08:00")).toBe(true)
expect(checkIfDateIsLater("2021-02-12T13:41:00+03:00","2021-01-12T13:41:00+03:00")).toBe(false)

expect(checkIfDateIsLater("2014-11-30T23:00:00-08:00","2015-11-30T23:00:00-08:00")).toBe(true)
expect(checkIfDateIsLater("2021-01-12T13:42:00+03:00","2020-01-12T13:42:00+03:00")).toBe(false)
})

0 comments on commit ea5fc05

Please sign in to comment.