@checkdigit/time 4.0.0-PR.18-81a3 → 4.0.0-PR.18-e0fa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/package.json +1 -1
- package/src/date-fns/_lib/addLeadingZeros/test.mts +0 -12
- package/src/date-fns/_lib/getRoundingMethod/test.mts +0 -50
- package/src/date-fns/_lib/getTimezoneOffsetInMilliseconds/test.mts +0 -25
- package/src/date-fns/add/test.mts +0 -95
- package/src/date-fns/addBusinessDays/test.mts +0 -78
- package/src/date-fns/addDays/test.mts +0 -90
- package/src/date-fns/addHours/test.mts +0 -30
- package/src/date-fns/addISOWeekYears/test.mts +0 -41
- package/src/date-fns/addMilliseconds/test.mts +0 -30
- package/src/date-fns/addMinutes/test.mts +0 -30
- package/src/date-fns/addMonths/test.mts +0 -123
- package/src/date-fns/addQuarters/test.mts +0 -47
- package/src/date-fns/addSeconds/test.mts +0 -30
- package/src/date-fns/addWeeks/test.mts +0 -30
- package/src/date-fns/addYears/test.mts +0 -46
- package/src/date-fns/areIntervalsOverlapping/test.mts +0 -231
- package/src/date-fns/clamp/test.mts +0 -36
- package/src/date-fns/closestIndexTo/test.mts +0 -51
- package/src/date-fns/closestTo/test.mts +0 -49
- package/src/date-fns/compareAsc/test.mts +0 -58
- package/src/date-fns/compareDesc/test.mts +0 -58
- package/src/date-fns/constructFrom/test.mts +0 -47
- package/src/date-fns/constructNow/test.mts +0 -37
- package/src/date-fns/daysToWeeks/test.mts +0 -36
- package/src/date-fns/differenceInBusinessDays/test.mts +0 -102
- package/src/date-fns/differenceInCalendarDays/test.mts +0 -206
- package/src/date-fns/differenceInCalendarISOWeekYears/test.mts +0 -93
- package/src/date-fns/differenceInCalendarISOWeeks/test.mts +0 -89
- package/src/date-fns/differenceInCalendarMonths/test.mts +0 -82
- package/src/date-fns/differenceInCalendarQuarters/test.mts +0 -82
- package/src/date-fns/differenceInCalendarWeeks/test.mts +0 -136
- package/src/date-fns/differenceInCalendarYears/test.mts +0 -82
- package/src/date-fns/differenceInDays/test.mts +0 -175
- package/src/date-fns/differenceInHours/test.mts +0 -122
- package/src/date-fns/differenceInISOWeekYears/test.mts +0 -93
- package/src/date-fns/differenceInMilliseconds/test.mts +0 -53
- package/src/date-fns/differenceInMinutes/test.mts +0 -123
- package/src/date-fns/differenceInMonths/test.mts +0 -121
- package/src/date-fns/differenceInQuarters/test.mts +0 -109
- package/src/date-fns/differenceInSeconds/test.mts +0 -144
- package/src/date-fns/differenceInWeeks/test.mts +0 -111
- package/src/date-fns/differenceInYears/test.mts +0 -97
- package/src/date-fns/eachDayOfInterval/test.mts +0 -164
- package/src/date-fns/eachHourOfInterval/test.mts +0 -154
- package/src/date-fns/eachMinuteOfInterval/test.mts +0 -159
- package/src/date-fns/eachMonthOfInterval/test.mts +0 -151
- package/src/date-fns/eachQuarterOfInterval/test.mts +0 -136
- package/src/date-fns/eachWeekOfInterval/test.mts +0 -177
- package/src/date-fns/eachWeekendOfInterval/test.mts +0 -67
- package/src/date-fns/eachWeekendOfMonth/test.mts +0 -23
- package/src/date-fns/eachWeekendOfYear/test.mts +0 -18
- package/src/date-fns/eachYearOfInterval/test.mts +0 -136
- package/src/date-fns/endOfDay/test.mts +0 -27
- package/src/date-fns/endOfDecade/test.mts +0 -32
- package/src/date-fns/endOfHour/test.mts +0 -26
- package/src/date-fns/endOfISOWeek/test.mts +0 -27
- package/src/date-fns/endOfISOWeekYear/test.mts +0 -36
- package/src/date-fns/endOfMinute/test.mts +0 -26
- package/src/date-fns/endOfMonth/test.mts +0 -41
- package/src/date-fns/endOfQuarter/test.mts +0 -27
- package/src/date-fns/endOfSecond/test.mts +0 -26
- package/src/date-fns/endOfToday/test.mts +0 -19
- package/src/date-fns/endOfTomorrow/test.mts +0 -29
- package/src/date-fns/endOfWeek/test.mts +0 -86
- package/src/date-fns/endOfYear/test.mts +0 -27
- package/src/date-fns/endOfYesterday/test.mts +0 -29
- package/src/date-fns/format/test.mts +0 -909
- package/src/date-fns/formatDistance/test.mts +0 -189
- package/src/date-fns/formatDistanceStrict/test.mts +0 -329
- package/src/date-fns/formatDistanceToNow/test.mts +0 -196
- package/src/date-fns/formatDistanceToNowStrict/test.mts +0 -293
- package/src/date-fns/formatDuration/test.mts +0 -74
- package/src/date-fns/formatISO/test.mts +0 -55
- package/src/date-fns/formatISO9075/test.mts +0 -35
- package/src/date-fns/formatISODuration/test.mts +0 -75
- package/src/date-fns/formatRFC3339/test.mts +0 -41
- package/src/date-fns/formatRFC7231/test.mts +0 -18
- package/src/date-fns/formatRelative/test.mts +0 -92
- package/src/date-fns/fp/_lib/convertToFP/test.mts +0 -114
- package/src/date-fns/fromUnixTime/test.mts +0 -14
- package/src/date-fns/getDate/test.mts +0 -19
- package/src/date-fns/getDay/test.mts +0 -19
- package/src/date-fns/getDayOfYear/test.mts +0 -27
- package/src/date-fns/getDaysInMonth/test.mts +0 -33
- package/src/date-fns/getDaysInYear/test.mts +0 -35
- package/src/date-fns/getDecade/test.mts +0 -24
- package/src/date-fns/getDefaultOptions/test.mts +0 -58
- package/src/date-fns/getHours/test.mts +0 -19
- package/src/date-fns/getISODay/test.mts +0 -24
- package/src/date-fns/getISOWeek/test.mts +0 -54
- package/src/date-fns/getISOWeekYear/test.mts +0 -27
- package/src/date-fns/getISOWeeksInYear/test.mts +0 -37
- package/src/date-fns/getMilliseconds/test.mts +0 -19
- package/src/date-fns/getMinutes/test.mts +0 -19
- package/src/date-fns/getMonth/test.mts +0 -19
- package/src/date-fns/getOverlappingDaysInIntervals/test.mts +0 -243
- package/src/date-fns/getQuarter/test.mts +0 -19
- package/src/date-fns/getSeconds/test.mts +0 -19
- package/src/date-fns/getTime/test.mts +0 -21
- package/src/date-fns/getUnixTime/test.mts +0 -26
- package/src/date-fns/getWeek/test.mts +0 -56
- package/src/date-fns/getWeekOfMonth/test.mts +0 -75
- package/src/date-fns/getWeekYear/test.mts +0 -49
- package/src/date-fns/getWeeksInMonth/test.mts +0 -51
- package/src/date-fns/getYear/test.mts +0 -19
- package/src/date-fns/hoursToMilliseconds/test.mts +0 -23
- package/src/date-fns/hoursToMinutes/test.mts +0 -25
- package/src/date-fns/hoursToSeconds/test.mts +0 -25
- package/src/date-fns/interval/test.mts +0 -42
- package/src/date-fns/intervalToDuration/test.mts +0 -235
- package/src/date-fns/intlFormat/test.mts +0 -88
- package/src/date-fns/intlFormatDistance/test.mts +0 -588
- package/src/date-fns/isAfter/test.mts +0 -39
- package/src/date-fns/isBefore/test.mts +0 -39
- package/src/date-fns/isDate/test.mts +0 -72
- package/src/date-fns/isEqual/test.mts +0 -34
- package/src/date-fns/isExists/test.mts +0 -14
- package/src/date-fns/isFirstDayOfMonth/test.mts +0 -25
- package/src/date-fns/isFriday/test.mts +0 -24
- package/src/date-fns/isFuture/test.mts +0 -34
- package/src/date-fns/isLastDayOfMonth/test.mts +0 -25
- package/src/date-fns/isLeapYear/test.mts +0 -35
- package/src/date-fns/isMatch/test.mts +0 -27
- package/src/date-fns/isMonday/test.mts +0 -24
- package/src/date-fns/isPast/test.mts +0 -34
- package/src/date-fns/isSameDay/test.mts +0 -37
- package/src/date-fns/isSameHour/test.mts +0 -37
- package/src/date-fns/isSameISOWeek/test.mts +0 -34
- package/src/date-fns/isSameISOWeekYear/test.mts +0 -48
- package/src/date-fns/isSameMinute/test.mts +0 -37
- package/src/date-fns/isSameMonth/test.mts +0 -34
- package/src/date-fns/isSameQuarter/test.mts +0 -34
- package/src/date-fns/isSameSecond/test.mts +0 -43
- package/src/date-fns/isSameWeek/test.mts +0 -58
- package/src/date-fns/isSameYear/test.mts +0 -34
- package/src/date-fns/isSaturday/test.mts +0 -24
- package/src/date-fns/isSunday/test.mts +0 -24
- package/src/date-fns/isThisHour/test.mts +0 -34
- package/src/date-fns/isThisISOWeek/test.mts +0 -34
- package/src/date-fns/isThisMinute/test.mts +0 -34
- package/src/date-fns/isThisMonth/test.mts +0 -34
- package/src/date-fns/isThisQuarter/test.mts +0 -34
- package/src/date-fns/isThisSecond/test.mts +0 -34
- package/src/date-fns/isThisWeek/test.mts +0 -39
- package/src/date-fns/isThisYear/test.mts +0 -34
- package/src/date-fns/isThursday/test.mts +0 -24
- package/src/date-fns/isToday/test.mts +0 -34
- package/src/date-fns/isTomorrow/test.mts +0 -34
- package/src/date-fns/isTuesday/test.mts +0 -24
- package/src/date-fns/isValid/test.mts +0 -24
- package/src/date-fns/isWednesday/test.mts +0 -24
- package/src/date-fns/isWeekend/test.mts +0 -24
- package/src/date-fns/isWithinInterval/test.mts +0 -92
- package/src/date-fns/isYesterday/test.mts +0 -34
- package/src/date-fns/lastDayOfDecade/test.mts +0 -32
- package/src/date-fns/lastDayOfISOWeek/test.mts +0 -27
- package/src/date-fns/lastDayOfISOWeekYear/test.mts +0 -36
- package/src/date-fns/lastDayOfMonth/test.mts +0 -41
- package/src/date-fns/lastDayOfQuarter/test.mts +0 -27
- package/src/date-fns/lastDayOfWeek/test.mts +0 -86
- package/src/date-fns/lastDayOfYear/test.mts +0 -27
- package/src/date-fns/lightFormat/test.mts +0 -126
- package/src/date-fns/max/test.mts +0 -34
- package/src/date-fns/milliseconds/test.mts +0 -62
- package/src/date-fns/millisecondsToHours/test.mts +0 -24
- package/src/date-fns/millisecondsToMinutes/test.mts +0 -24
- package/src/date-fns/millisecondsToSeconds/test.mts +0 -24
- package/src/date-fns/min/test.mts +0 -34
- package/src/date-fns/minutesToHours/test.mts +0 -24
- package/src/date-fns/minutesToMilliseconds/test.mts +0 -23
- package/src/date-fns/minutesToSeconds/test.mts +0 -23
- package/src/date-fns/monthsToQuarters/test.mts +0 -24
- package/src/date-fns/monthsToYears/test.mts +0 -24
- package/src/date-fns/nextDay/test.mts +0 -44
- package/src/date-fns/nextFriday/test.mts +0 -24
- package/src/date-fns/nextMonday/test.mts +0 -24
- package/src/date-fns/nextSaturday/test.mts +0 -24
- package/src/date-fns/nextSunday/test.mts +0 -24
- package/src/date-fns/nextThursday/test.mts +0 -24
- package/src/date-fns/nextTuesday/test.mts +0 -23
- package/src/date-fns/nextWednesday/test.mts +0 -24
- package/src/date-fns/parse/test.mts +0 -2202
- package/src/date-fns/parseISO/test.mts +0 -362
- package/src/date-fns/parseJSON/test.mts +0 -129
- package/src/date-fns/previousDay/test.mts +0 -42
- package/src/date-fns/previousFriday/test.mts +0 -22
- package/src/date-fns/previousMonday/test.mts +0 -22
- package/src/date-fns/previousSaturday/test.mts +0 -22
- package/src/date-fns/previousSunday/test.mts +0 -22
- package/src/date-fns/previousThursday/test.mts +0 -22
- package/src/date-fns/previousTuesday/test.mts +0 -22
- package/src/date-fns/previousWednesday/test.mts +0 -22
- package/src/date-fns/quartersToMonths/test.mts +0 -24
- package/src/date-fns/quartersToYears/test.mts +0 -24
- package/src/date-fns/roundToNearestHours/test.mts +0 -200
- package/src/date-fns/roundToNearestMinutes/test.mts +0 -208
- package/src/date-fns/secondsToHours/test.mts +0 -24
- package/src/date-fns/secondsToMilliseconds/test.mts +0 -14
- package/src/date-fns/secondsToMinutes/test.mts +0 -24
- package/src/date-fns/set/test.mts +0 -121
- package/src/date-fns/setDate/test.mts +0 -30
- package/src/date-fns/setDay/test.mts +0 -112
- package/src/date-fns/setDayOfYear/test.mts +0 -30
- package/src/date-fns/setDefaultOptions/test.mts +0 -498
- package/src/date-fns/setHours/test.mts +0 -30
- package/src/date-fns/setISODay/test.mts +0 -59
- package/src/date-fns/setISOWeek/test.mts +0 -41
- package/src/date-fns/setISOWeekYear/test.mts +0 -50
- package/src/date-fns/setMilliseconds/test.mts +0 -30
- package/src/date-fns/setMinutes/test.mts +0 -30
- package/src/date-fns/setMonth/test.mts +0 -46
- package/src/date-fns/setQuarter/test.mts +0 -46
- package/src/date-fns/setSeconds/test.mts +0 -30
- package/src/date-fns/setWeek/test.mts +0 -63
- package/src/date-fns/setWeekYear/test.mts +0 -72
- package/src/date-fns/setYear/test.mts +0 -30
- package/src/date-fns/startOfDay/test.mts +0 -27
- package/src/date-fns/startOfDecade/test.mts +0 -32
- package/src/date-fns/startOfHour/test.mts +0 -27
- package/src/date-fns/startOfISOWeek/test.mts +0 -27
- package/src/date-fns/startOfISOWeekYear/test.mts +0 -41
- package/src/date-fns/startOfMinute/test.mts +0 -27
- package/src/date-fns/startOfMonth/test.mts +0 -27
- package/src/date-fns/startOfQuarter/test.mts +0 -27
- package/src/date-fns/startOfSecond/test.mts +0 -27
- package/src/date-fns/startOfToday/test.mts +0 -19
- package/src/date-fns/startOfTomorrow/test.mts +0 -29
- package/src/date-fns/startOfWeek/test.mts +0 -86
- package/src/date-fns/startOfWeekYear/test.mts +0 -58
- package/src/date-fns/startOfYear/test.mts +0 -38
- package/src/date-fns/startOfYesterday/test.mts +0 -29
- package/src/date-fns/sub/test.mts +0 -83
- package/src/date-fns/subBusinessDays/test.mts +0 -40
- package/src/date-fns/subDays/test.mts +0 -30
- package/src/date-fns/subHours/test.mts +0 -30
- package/src/date-fns/subISOWeekYears/test.mts +0 -41
- package/src/date-fns/subMilliseconds/test.mts +0 -30
- package/src/date-fns/subMinutes/test.mts +0 -30
- package/src/date-fns/subMonths/test.mts +0 -47
- package/src/date-fns/subQuarters/test.mts +0 -47
- package/src/date-fns/subSeconds/test.mts +0 -30
- package/src/date-fns/subWeeks/test.mts +0 -30
- package/src/date-fns/subYears/test.mts +0 -46
- package/src/date-fns/toDate/test.mts +0 -35
- package/src/date-fns/weeksToDays/test.mts +0 -24
- package/src/date-fns/yearsToDays/test.mts +0 -24
- package/src/date-fns/yearsToMonths/test.mts +0 -24
- package/src/date-fns/yearsToQuarters/test.mts +0 -24
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { eachMonthOfInterval } from './index';
|
|
3
|
-
|
|
4
|
-
describe('eachMonthOfInterval', () => {
|
|
5
|
-
it('returns an array with starts of months from the month of the start date to the month of the end date', () => {
|
|
6
|
-
const result = eachMonthOfInterval({
|
|
7
|
-
start: new Date(2014, 2 /* Mar */, 6),
|
|
8
|
-
end: new Date(2014, 7 /* Aug */, 12),
|
|
9
|
-
});
|
|
10
|
-
expect(result).toEqual([
|
|
11
|
-
new Date(2014, 2 /* Mar */, 1),
|
|
12
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
13
|
-
new Date(2014, 4 /* May */, 1),
|
|
14
|
-
new Date(2014, 5 /* Jun */, 1),
|
|
15
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
16
|
-
new Date(2014, 7 /* Aug */, 1),
|
|
17
|
-
]);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('accepts timestamps', () => {
|
|
21
|
-
const result = eachMonthOfInterval({
|
|
22
|
-
start: new Date(2014, 2 /* Mar */, 6).getTime(),
|
|
23
|
-
end: new Date(2014, 7 /* Aug */, 12).getTime(),
|
|
24
|
-
});
|
|
25
|
-
expect(result).toEqual([
|
|
26
|
-
new Date(2014, 2 /* Mar */, 1),
|
|
27
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
28
|
-
new Date(2014, 4 /* May */, 1),
|
|
29
|
-
new Date(2014, 5 /* Jun */, 1),
|
|
30
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
31
|
-
new Date(2014, 7 /* Aug */, 1),
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('handles the dates that are not starts of days', () => {
|
|
36
|
-
const result = eachMonthOfInterval({
|
|
37
|
-
start: new Date(2014, 2 /* Mar */, 6, 6, 35),
|
|
38
|
-
end: new Date(2014, 7 /* Aug */, 12, 22, 15),
|
|
39
|
-
});
|
|
40
|
-
expect(result).toEqual([
|
|
41
|
-
new Date(2014, 2 /* Mar */, 1),
|
|
42
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
43
|
-
new Date(2014, 4 /* May */, 1),
|
|
44
|
-
new Date(2014, 5 /* Jun */, 1),
|
|
45
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
46
|
-
new Date(2014, 7 /* Aug */, 1),
|
|
47
|
-
]);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('handles the dates that are not containing days', () => {
|
|
51
|
-
const result = eachMonthOfInterval({
|
|
52
|
-
start: new Date(2014, 2 /* Mar */),
|
|
53
|
-
end: new Date(2014, 7 /* Aug */),
|
|
54
|
-
});
|
|
55
|
-
expect(result).toEqual([
|
|
56
|
-
new Date(2014, 2 /* Mar */, 1),
|
|
57
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
58
|
-
new Date(2014, 4 /* May */, 1),
|
|
59
|
-
new Date(2014, 5 /* Jun */, 1),
|
|
60
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
61
|
-
new Date(2014, 7 /* Aug */, 1),
|
|
62
|
-
]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('returns one month if the both arguments are on the same month', () => {
|
|
66
|
-
const result = eachMonthOfInterval({
|
|
67
|
-
start: new Date(2014, 9 /* Oct */, 6, 14),
|
|
68
|
-
end: new Date(2014, 9 /* Oct */, 9, 15),
|
|
69
|
-
});
|
|
70
|
-
expect(result).toEqual([new Date(2014, 9 /* Oct */, 1)]);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('returns one month if the both arguments are the same', () => {
|
|
74
|
-
const result = eachMonthOfInterval({
|
|
75
|
-
start: new Date(2014, 9 /* Oct */, 6, 14),
|
|
76
|
-
end: new Date(2014, 9 /* Oct */, 6, 14),
|
|
77
|
-
});
|
|
78
|
-
expect(result).toEqual([new Date(2014, 9 /* Oct */, 1)]);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('returns reversed array if the start date is after the end date', () => {
|
|
82
|
-
const result = eachMonthOfInterval({
|
|
83
|
-
start: new Date(2014, 7 /* Aug */, 12),
|
|
84
|
-
end: new Date(2014, 2 /* Mar */, 6),
|
|
85
|
-
});
|
|
86
|
-
expect(result).toEqual([
|
|
87
|
-
new Date(2014, 7 /* Aug */, 1),
|
|
88
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
89
|
-
new Date(2014, 5 /* Jun */, 1),
|
|
90
|
-
new Date(2014, 4 /* May */, 1),
|
|
91
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
92
|
-
new Date(2014, 2 /* Mar */, 1),
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('returns an empty array if the start date is `Invalid Date`', () => {
|
|
97
|
-
const result = eachMonthOfInterval({
|
|
98
|
-
start: new Date(NaN),
|
|
99
|
-
end: new Date(2014, 9 /* Oct */, 6),
|
|
100
|
-
});
|
|
101
|
-
expect(result).toEqual([]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('returns an empty array if the end date is `Invalid Date`', () => {
|
|
105
|
-
const result = eachMonthOfInterval({
|
|
106
|
-
start: new Date(2014, 9 /* Oct */, 12),
|
|
107
|
-
end: new Date(NaN),
|
|
108
|
-
});
|
|
109
|
-
expect(result).toEqual([]);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('returns an empty array if both of the properties are `Invalid Date`', () => {
|
|
113
|
-
const result = eachMonthOfInterval({
|
|
114
|
-
start: new Date(NaN),
|
|
115
|
-
end: new Date(NaN),
|
|
116
|
-
});
|
|
117
|
-
expect(result).toEqual([]);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe('options.step', () => {
|
|
121
|
-
const interval = {
|
|
122
|
-
start: new Date(2014, 2 /* Mar */, 6),
|
|
123
|
-
end: new Date(2014, 7 /* Aug */, 12),
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
it('returns an array with starts of days from the day of the start date to the day of the end date with the given step', () => {
|
|
127
|
-
const result = eachMonthOfInterval(interval, { step: 3 });
|
|
128
|
-
expect(result).toEqual([new Date(2014, 2 /* Mar */, 1), new Date(2014, 5 /* Jun */, 1)]);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('returns reversed array if `options.step` is negative', () => {
|
|
132
|
-
const result = eachMonthOfInterval(interval, { step: -3 });
|
|
133
|
-
expect(result).toEqual([new Date(2014, 5 /* Jun */, 1), new Date(2014, 2 /* Mar */, 1)]);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('reverses array twice if `options.step` is negative and the interval is negative too', () => {
|
|
137
|
-
const result = eachMonthOfInterval({ start: interval.end, end: interval.start }, { step: -3 });
|
|
138
|
-
expect(result).toEqual([new Date(2014, 2 /* Mar */, 1), new Date(2014, 5 /* Jun */, 1)]);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('returns empty array if `options.step` is less than 1', () => {
|
|
142
|
-
const result = eachMonthOfInterval(interval, { step: 0 });
|
|
143
|
-
expect(result).toEqual([]);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('returns empty array if `options.step` is NaN', () => {
|
|
147
|
-
const result = eachMonthOfInterval(interval, { step: NaN });
|
|
148
|
-
expect(result).toEqual([]);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { eachQuarterOfInterval } from './index';
|
|
3
|
-
|
|
4
|
-
describe('eachQuarterOfInterval', () => {
|
|
5
|
-
it('returns an array with starts of quarters from the quarter of the start date to the quarter of the end date', () => {
|
|
6
|
-
const result = eachQuarterOfInterval({
|
|
7
|
-
start: new Date(2014, 2 /* Mar */, 6),
|
|
8
|
-
end: new Date(2014, 7 /* Aug */, 12),
|
|
9
|
-
});
|
|
10
|
-
expect(result).toEqual([
|
|
11
|
-
new Date(2014, 0 /* Jan */, 1),
|
|
12
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
13
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
14
|
-
]);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('accepts timestamps', () => {
|
|
18
|
-
const result = eachQuarterOfInterval({
|
|
19
|
-
start: new Date(2014, 2 /* Mar */, 6).getTime(),
|
|
20
|
-
end: new Date(2014, 7 /* Aug */, 12).getTime(),
|
|
21
|
-
});
|
|
22
|
-
expect(result).toEqual([
|
|
23
|
-
new Date(2014, 0 /* Jan */, 1),
|
|
24
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
25
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
26
|
-
]);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('handles the dates that are not starts of days', () => {
|
|
30
|
-
const result = eachQuarterOfInterval({
|
|
31
|
-
start: new Date(2014, 2 /* Mar */, 6, 6, 35),
|
|
32
|
-
end: new Date(2014, 7 /* Aug */, 12, 22, 15),
|
|
33
|
-
});
|
|
34
|
-
expect(result).toEqual([
|
|
35
|
-
new Date(2014, 0 /* Jan */, 1),
|
|
36
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
37
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
38
|
-
]);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('handles the dates that are not containing days', () => {
|
|
42
|
-
const result = eachQuarterOfInterval({
|
|
43
|
-
start: new Date(2014, 2 /* Mar */),
|
|
44
|
-
end: new Date(2014, 7 /* Oct */),
|
|
45
|
-
});
|
|
46
|
-
expect(result).toEqual([
|
|
47
|
-
new Date(2014, 0 /* Jan */, 1),
|
|
48
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
49
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
50
|
-
]);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('returns one quarter if the both arguments are on the same quarter', () => {
|
|
54
|
-
const result = eachQuarterOfInterval({
|
|
55
|
-
start: new Date(2014, 0 /* Jan */, 6, 14),
|
|
56
|
-
end: new Date(2014, 2 /* Feb */, 9, 15),
|
|
57
|
-
});
|
|
58
|
-
expect(result).toEqual([new Date(2014, 0 /* Jan */, 1)]);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('returns one quarter if the both arguments are the same', () => {
|
|
62
|
-
const result = eachQuarterOfInterval({
|
|
63
|
-
start: new Date(2014, 9 /* Oct */, 6, 14),
|
|
64
|
-
end: new Date(2014, 9 /* Oct */, 6, 14),
|
|
65
|
-
});
|
|
66
|
-
expect(result).toEqual([new Date(2014, 9 /* Oct */, 1)]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('returns reversed array if the start date is after the end date', () => {
|
|
70
|
-
const result = eachQuarterOfInterval({
|
|
71
|
-
start: new Date(2014, 7 /* Aug */, 12),
|
|
72
|
-
end: new Date(2014, 2 /* Mar */, 6),
|
|
73
|
-
});
|
|
74
|
-
expect(result).toEqual([
|
|
75
|
-
new Date(2014, 6 /* Jul */, 1),
|
|
76
|
-
new Date(2014, 3 /* Apr */, 1),
|
|
77
|
-
new Date(2014, 0 /* Jan */, 1),
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('returns an empty array if the start date is `Invalid Date`', () => {
|
|
82
|
-
const result = eachQuarterOfInterval({
|
|
83
|
-
start: new Date(NaN),
|
|
84
|
-
end: new Date(2014, 9 /* Oct */, 6),
|
|
85
|
-
});
|
|
86
|
-
expect(result).toEqual([]);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('returns an empty array if the end date is `Invalid Date`', () => {
|
|
90
|
-
const result = eachQuarterOfInterval({
|
|
91
|
-
start: new Date(2014, 9 /* Oct */, 12),
|
|
92
|
-
end: new Date(NaN),
|
|
93
|
-
});
|
|
94
|
-
expect(result).toEqual([]);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('returns an empty array if both of the properties are `Invalid Date`', () => {
|
|
98
|
-
const result = eachQuarterOfInterval({
|
|
99
|
-
start: new Date(NaN),
|
|
100
|
-
end: new Date(NaN),
|
|
101
|
-
});
|
|
102
|
-
expect(result).toEqual([]);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe('options.step', () => {
|
|
106
|
-
const interval = {
|
|
107
|
-
start: new Date(2014, 2 /* Mar */, 6),
|
|
108
|
-
end: new Date(2014, 7 /* Aug */, 12),
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
it('returns an array with starts of days from the day of the start date to the day of the end date with the given step', () => {
|
|
112
|
-
const result = eachQuarterOfInterval(interval, { step: 2 });
|
|
113
|
-
expect(result).toEqual([new Date(2014, 0 /* Jan */, 1), new Date(2014, 6 /* Jul */, 1)]);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('returns reversed array if `options.step` is negative', () => {
|
|
117
|
-
const result = eachQuarterOfInterval(interval, { step: -2 });
|
|
118
|
-
expect(result).toEqual([new Date(2014, 6 /* Jul */, 1), new Date(2014, 0 /* Jan */, 1)]);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('reverses array twice if `options.step` is negative and the interval is negative too', () => {
|
|
122
|
-
const result = eachQuarterOfInterval({ start: interval.end, end: interval.start }, { step: -2 });
|
|
123
|
-
expect(result).toEqual([new Date(2014, 0 /* Jan */, 1), new Date(2014, 6 /* Jul */, 1)]);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('returns empty array if `options.step` is less than 1', () => {
|
|
127
|
-
const result = eachQuarterOfInterval(interval, { step: 0 });
|
|
128
|
-
expect(result).toEqual([]);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('returns empty array if `options.step` is NaN', () => {
|
|
132
|
-
const result = eachQuarterOfInterval(interval, { step: NaN });
|
|
133
|
-
expect(result).toEqual([]);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
});
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { eachWeekOfInterval } from './index';
|
|
3
|
-
|
|
4
|
-
describe('eachWeekOfInterval', () => {
|
|
5
|
-
it('returns an array with starts of weeks from the week of the start date to the week of the end date', () => {
|
|
6
|
-
const result = eachWeekOfInterval({
|
|
7
|
-
start: new Date(2014, 9 /* Oct */, 6),
|
|
8
|
-
end: new Date(2014, 10 /* Nov */, 23),
|
|
9
|
-
});
|
|
10
|
-
expect(result).toEqual([
|
|
11
|
-
new Date(2014, 9 /* Oct */, 5),
|
|
12
|
-
new Date(2014, 9 /* Oct */, 12),
|
|
13
|
-
new Date(2014, 9 /* Oct */, 19),
|
|
14
|
-
new Date(2014, 9 /* Oct */, 26),
|
|
15
|
-
new Date(2014, 10 /* Nov */, 2),
|
|
16
|
-
new Date(2014, 10 /* Nov */, 9),
|
|
17
|
-
new Date(2014, 10 /* Nov */, 16),
|
|
18
|
-
new Date(2014, 10 /* Nov */, 23),
|
|
19
|
-
]);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('accepts timestamps', () => {
|
|
23
|
-
const result = eachWeekOfInterval({
|
|
24
|
-
start: new Date(2014, 9 /* Oct */, 6).getTime(),
|
|
25
|
-
end: new Date(2014, 10 /* Nov */, 23).getTime(),
|
|
26
|
-
});
|
|
27
|
-
expect(result).toEqual([
|
|
28
|
-
new Date(2014, 9 /* Oct */, 5),
|
|
29
|
-
new Date(2014, 9 /* Oct */, 12),
|
|
30
|
-
new Date(2014, 9 /* Oct */, 19),
|
|
31
|
-
new Date(2014, 9 /* Oct */, 26),
|
|
32
|
-
new Date(2014, 10 /* Nov */, 2),
|
|
33
|
-
new Date(2014, 10 /* Nov */, 9),
|
|
34
|
-
new Date(2014, 10 /* Nov */, 16),
|
|
35
|
-
new Date(2014, 10 /* Nov */, 23),
|
|
36
|
-
]);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('handles the dates that are not starts/ends of days and weeks', () => {
|
|
40
|
-
const result = eachWeekOfInterval({
|
|
41
|
-
start: new Date(2014, 9 /* Oct */, 6, 6, 35),
|
|
42
|
-
end: new Date(2014, 10 /* Nov */, 25, 22, 16),
|
|
43
|
-
});
|
|
44
|
-
expect(result).toEqual([
|
|
45
|
-
new Date(2014, 9 /* Oct */, 5),
|
|
46
|
-
new Date(2014, 9 /* Oct */, 12),
|
|
47
|
-
new Date(2014, 9 /* Oct */, 19),
|
|
48
|
-
new Date(2014, 9 /* Oct */, 26),
|
|
49
|
-
new Date(2014, 10 /* Nov */, 2),
|
|
50
|
-
new Date(2014, 10 /* Nov */, 9),
|
|
51
|
-
new Date(2014, 10 /* Nov */, 16),
|
|
52
|
-
new Date(2014, 10 /* Nov */, 23),
|
|
53
|
-
]);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('considers the weekStartsOn option', () => {
|
|
57
|
-
const result = eachWeekOfInterval(
|
|
58
|
-
{
|
|
59
|
-
start: new Date(2014, 9 /* Oct */, 6, 6, 35),
|
|
60
|
-
end: new Date(2014, 10 /* Nov */, 25, 22, 15),
|
|
61
|
-
},
|
|
62
|
-
{ weekStartsOn: 2 },
|
|
63
|
-
);
|
|
64
|
-
expect(result).toEqual([
|
|
65
|
-
new Date(2014, 8 /* Sep */, 30),
|
|
66
|
-
new Date(2014, 9 /* Oct */, 7),
|
|
67
|
-
new Date(2014, 9 /* Oct */, 14),
|
|
68
|
-
new Date(2014, 9 /* Oct */, 21),
|
|
69
|
-
new Date(2014, 9 /* Oct */, 28),
|
|
70
|
-
new Date(2014, 10 /* Nov */, 4),
|
|
71
|
-
new Date(2014, 10 /* Nov */, 11),
|
|
72
|
-
new Date(2014, 10 /* Nov */, 18),
|
|
73
|
-
new Date(2014, 10 /* Nov */, 25),
|
|
74
|
-
]);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('returns one week if the both arguments are on the same week', () => {
|
|
78
|
-
const result = eachWeekOfInterval({
|
|
79
|
-
start: new Date(2014, 9 /* Oct */, 6, 14),
|
|
80
|
-
end: new Date(2014, 9 /* Oct */, 8, 15),
|
|
81
|
-
});
|
|
82
|
-
expect(result).toEqual([new Date(2014, 9 /* Oct */, 5)]);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('returns one day if the both arguments are the same', () => {
|
|
86
|
-
const result = eachWeekOfInterval({
|
|
87
|
-
start: new Date(2014, 9 /* Oct */, 6, 14),
|
|
88
|
-
end: new Date(2014, 9 /* Oct */, 6, 14),
|
|
89
|
-
});
|
|
90
|
-
expect(result).toEqual([new Date(2014, 9 /* Oct */, 5)]);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('returns reversed array if the start date is after the end date', () => {
|
|
94
|
-
const result = eachWeekOfInterval({
|
|
95
|
-
start: new Date(2014, 10 /* Nov */, 23),
|
|
96
|
-
end: new Date(2014, 9 /* Oct */, 6),
|
|
97
|
-
});
|
|
98
|
-
expect(result).toEqual([
|
|
99
|
-
new Date(2014, 10 /* Nov */, 23),
|
|
100
|
-
new Date(2014, 10 /* Nov */, 16),
|
|
101
|
-
new Date(2014, 10 /* Nov */, 9),
|
|
102
|
-
new Date(2014, 10 /* Nov */, 2),
|
|
103
|
-
new Date(2014, 9 /* Oct */, 26),
|
|
104
|
-
new Date(2014, 9 /* Oct */, 19),
|
|
105
|
-
new Date(2014, 9 /* Oct */, 12),
|
|
106
|
-
new Date(2014, 9 /* Oct */, 5),
|
|
107
|
-
]);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('returns an empty array if the start date is `Invalid Date`', () => {
|
|
111
|
-
const result = eachWeekOfInterval({
|
|
112
|
-
start: new Date(NaN),
|
|
113
|
-
end: new Date(2014, 9 /* Oct */, 6),
|
|
114
|
-
});
|
|
115
|
-
expect(result).toEqual([]);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('returns an empty array if the end date is `Invalid Date`', () => {
|
|
119
|
-
const result = eachWeekOfInterval({
|
|
120
|
-
start: new Date(2014, 9 /* Oct */, 12),
|
|
121
|
-
end: new Date(NaN),
|
|
122
|
-
});
|
|
123
|
-
expect(result).toEqual([]);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('returns an empty array if both of the properties are `Invalid Date`', () => {
|
|
127
|
-
const result = eachWeekOfInterval({
|
|
128
|
-
start: new Date(NaN),
|
|
129
|
-
end: new Date(NaN),
|
|
130
|
-
});
|
|
131
|
-
expect(result).toEqual([]);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe('options.step', () => {
|
|
135
|
-
const interval = {
|
|
136
|
-
start: new Date(2014, 9 /* Oct */, 6),
|
|
137
|
-
end: new Date(2014, 10 /* Nov */, 23),
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
it('returns an array with starts of days from the day of the start date to the day of the end date with the given step', () => {
|
|
141
|
-
const result = eachWeekOfInterval(interval, { step: 3 });
|
|
142
|
-
expect(result).toEqual([
|
|
143
|
-
new Date(2014, 9 /* Oct */, 5),
|
|
144
|
-
new Date(2014, 9 /* Oct */, 26),
|
|
145
|
-
new Date(2014, 10 /* Nov */, 16),
|
|
146
|
-
]);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('returns reversed array if `options.step` is negative', () => {
|
|
150
|
-
const result = eachWeekOfInterval(interval, { step: -3 });
|
|
151
|
-
expect(result).toEqual([
|
|
152
|
-
new Date(2014, 10 /* Nov */, 16),
|
|
153
|
-
new Date(2014, 9 /* Oct */, 26),
|
|
154
|
-
new Date(2014, 9 /* Oct */, 5),
|
|
155
|
-
]);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('reverses array twice if `options.step` is negative and the interval is negative too', () => {
|
|
159
|
-
const result = eachWeekOfInterval({ start: interval.end, end: interval.start }, { step: -3 });
|
|
160
|
-
expect(result).toEqual([
|
|
161
|
-
new Date(2014, 9 /* Oct */, 5),
|
|
162
|
-
new Date(2014, 9 /* Oct */, 26),
|
|
163
|
-
new Date(2014, 10 /* Nov */, 16),
|
|
164
|
-
]);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('returns empty array if `options.step` is less than 1', () => {
|
|
168
|
-
const result = eachWeekOfInterval(interval, { step: 0 });
|
|
169
|
-
expect(result).toEqual([]);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('returns empty array if `options.step` is NaN', () => {
|
|
173
|
-
const result = eachWeekOfInterval(interval, { step: NaN });
|
|
174
|
-
expect(result).toEqual([]);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { eachWeekendOfInterval } from './index';
|
|
3
|
-
|
|
4
|
-
describe('eachWeekendOfInterval', () => {
|
|
5
|
-
it('returns all weekends within the interval', () => {
|
|
6
|
-
const result = eachWeekendOfInterval({
|
|
7
|
-
start: new Date(2018, 8 /* Sept */, 17),
|
|
8
|
-
end: new Date(2018, 8 /* Sept */, 30),
|
|
9
|
-
});
|
|
10
|
-
expect(result).toEqual([
|
|
11
|
-
new Date(2018, 8 /* Sept */, 22),
|
|
12
|
-
new Date(2018, 8 /* Sept */, 23),
|
|
13
|
-
new Date(2018, 8 /* Sept */, 29),
|
|
14
|
-
new Date(2018, 8 /* Sept */, 30),
|
|
15
|
-
]);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('returns all weekends within the interval when starting on a weekend', () => {
|
|
19
|
-
const result = eachWeekendOfInterval({
|
|
20
|
-
start: new Date(2018, 8 /* Sept */, 22),
|
|
21
|
-
end: new Date(2018, 8 /* Sept */, 30),
|
|
22
|
-
});
|
|
23
|
-
expect(result).toEqual([
|
|
24
|
-
new Date(2018, 8 /* Sept */, 22),
|
|
25
|
-
new Date(2018, 8 /* Sept */, 23),
|
|
26
|
-
new Date(2018, 8 /* Sept */, 29),
|
|
27
|
-
new Date(2018, 8 /* Sept */, 30),
|
|
28
|
-
]);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('returns reversed array if the start date is after the end date', () => {
|
|
32
|
-
const result = eachWeekendOfInterval({
|
|
33
|
-
start: new Date(2018, 8 /* Sept */, 30),
|
|
34
|
-
end: new Date(2018, 8 /* Sept */, 17),
|
|
35
|
-
});
|
|
36
|
-
expect(result).toEqual([
|
|
37
|
-
new Date(2018, 8 /* Sept */, 30),
|
|
38
|
-
new Date(2018, 8 /* Sept */, 29),
|
|
39
|
-
new Date(2018, 8 /* Sept */, 23),
|
|
40
|
-
new Date(2018, 8 /* Sept */, 22),
|
|
41
|
-
]);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('returns an empty array if the start date is `Invalid Date`', () => {
|
|
45
|
-
const result = eachWeekendOfInterval({
|
|
46
|
-
start: new Date(NaN),
|
|
47
|
-
end: new Date(2019, 11 /* Dec */, 31),
|
|
48
|
-
});
|
|
49
|
-
expect(result).toEqual([]);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('returns an empty array if the end date is `Invalid Date`', () => {
|
|
53
|
-
const result = eachWeekendOfInterval({
|
|
54
|
-
start: new Date(2019, 0 /* Jan */, 1),
|
|
55
|
-
end: new Date(NaN),
|
|
56
|
-
});
|
|
57
|
-
expect(result).toEqual([]);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('returns an empty array if both of the properties are `Invalid Date`', () => {
|
|
61
|
-
const result = eachWeekendOfInterval({
|
|
62
|
-
start: new Date(NaN),
|
|
63
|
-
end: new Date(NaN),
|
|
64
|
-
});
|
|
65
|
-
expect(result).toEqual([]);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { eachWeekendOfMonth } from './index';
|
|
3
|
-
|
|
4
|
-
describe('eachWeekendOfMonth', () => {
|
|
5
|
-
it('returns all weekends of the given month', () => {
|
|
6
|
-
const result = eachWeekendOfMonth(new Date(2022, 1, 20));
|
|
7
|
-
expect(result).toEqual([
|
|
8
|
-
new Date(2022, 1, 5),
|
|
9
|
-
new Date(2022, 1, 6),
|
|
10
|
-
new Date(2022, 1, 12),
|
|
11
|
-
new Date(2022, 1, 13),
|
|
12
|
-
new Date(2022, 1, 19),
|
|
13
|
-
new Date(2022, 1, 20),
|
|
14
|
-
new Date(2022, 1, 26),
|
|
15
|
-
new Date(2022, 1, 27),
|
|
16
|
-
]);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('returns an empty asrray when the expected year is an Invalid Date', () => {
|
|
20
|
-
const result = eachWeekendOfMonth(new Date(NaN));
|
|
21
|
-
expect(result).toEqual([]);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { eachWeekendOfYear } from './index';
|
|
3
|
-
import { isWeekend } from '../isWeekend/index';
|
|
4
|
-
|
|
5
|
-
describe('eachWeekendOfYear', () => {
|
|
6
|
-
it('returns all weekends of the given year', () => {
|
|
7
|
-
const result = eachWeekendOfYear(new Date(2020, 0, 1));
|
|
8
|
-
expect(result.length).toBe(104);
|
|
9
|
-
expect(result.every(isWeekend)).toBe(true);
|
|
10
|
-
expect(result[0]).toEqual(new Date(2020, 0, 4));
|
|
11
|
-
expect(result[103]).toEqual(new Date(2020, 11, 27));
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('returns an empty asrray when the expected year is an Invalid Date', () => {
|
|
15
|
-
const result = eachWeekendOfYear(new Date(NaN));
|
|
16
|
-
expect(result).toEqual([]);
|
|
17
|
-
});
|
|
18
|
-
});
|