-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_openholidaysapi.nim
34 lines (27 loc) · 1013 Bytes
/
test_openholidaysapi.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import std/[unittest, strutils, times, sequtils]
import holidapi/api/openholidaysapi
const year: int = 2024
var
holidaysYear: seq[Holiday]
holidaysMultipleYears: seq[Holiday]
test "Fetching holidays - year":
holidaysYear = Germany.getHolidays(year)
check holidaysYear.len() != 0
test "Reading values - year":
for holiday in holidaysYear:
check holiday.name != ""
if holiday.nationwide.get():
check holiday.regions.len() == 0
else:
check holiday.regions.len() != 0
test "Fetching holidays - custom range":
holidaysMultipleYears = Germany.getHolidays(
dateFrom = dateTime(year - 1, mJan, 1),
dateTill = dateTime(year + 1, mDec, 31)
)
check holidaysMultipleYears.len() > holidaysYear.len()
test "Reading values - custom range":
var names: seq[string]
for holiday in holidaysMultipleYears:
names.add holiday.name
check names.deduplicate().len() < names.len() and names.deduplicate().len() != 0