This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
open Jest; | ||
|
||
open Js.Date; | ||
|
||
describe("addBusinessDays", () => { | ||
open ExpectJs; | ||
|
||
test("adds 0 business days", () => { | ||
let date = makeWithYMD(~year=2020., ~month=0., ~date=1., ()); | ||
let expectedDate = makeWithYMD(~year=2020., ~month=0., ~date=1., ()); | ||
|
||
date |> ReDate.addBusinessDays(0) |> expect |> toEqual(expectedDate); | ||
}); | ||
|
||
test("adds 1 business day", () => { | ||
let date = makeWithYMD(~year=2020., ~month=0., ~date=1., ()); | ||
let expectedDate = makeWithYMD(~year=2020., ~month=0., ~date=2., ()); | ||
|
||
date |> ReDate.addBusinessDays(1) |> expect |> toEqual(expectedDate); | ||
}); | ||
|
||
test("adds 100 business days", () => { | ||
let date = makeWithYMD(~year=2020., ~month=0., ~date=1., ()); | ||
let expectedDate = makeWithYMD(~year=2020., ~month=4., ~date=20., ()); | ||
|
||
date |> ReDate.addBusinessDays(100) |> expect |> toEqual(expectedDate); | ||
}); | ||
|
||
test("handles negative number", () => { | ||
let date = makeWithYMD(~year=2020., ~month=4., ~date=20., ()); | ||
let expectedDate = makeWithYMD(~year=2020., ~month=0., ~date=1., ()); | ||
|
||
date |> ReDate.addBusinessDays(-100) |> expect |> toEqual(expectedDate); | ||
}); | ||
|
||
test("returns Monday when 1 day is added on Friday", () => { | ||
let date = makeWithYMD(~year=2020., ~month=0., ~date=10., ()); | ||
let expectedDate = makeWithYMD(~year=2020., ~month=0., ~date=13., ()); | ||
|
||
date |> ReDate.addBusinessDays(1) |> expect |> toEqual(expectedDate); | ||
}); | ||
|
||
test("returns Monday when 1 day is added on Saturday", () => { | ||
let date = makeWithYMD(~year=2020., ~month=0., ~date=11., ()); | ||
let expectedDate = makeWithYMD(~year=2020., ~month=0., ~date=13., ()); | ||
|
||
date |> ReDate.addBusinessDays(1) |> expect |> toEqual(expectedDate); | ||
}); | ||
|
||
test("returns Monday when 1 day is added on Sunday", () => { | ||
let date = makeWithYMD(~year=2020., ~month=0., ~date=12., ()); | ||
let expectedDate = makeWithYMD(~year=2020., ~month=0., ~date=13., ()); | ||
|
||
date |> ReDate.addBusinessDays(1) |> expect |> toEqual(expectedDate); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters