@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,588 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { intlFormatDistance } from './index';
|
|
3
|
-
|
|
4
|
-
describe('intlFormatDistance', () => {
|
|
5
|
-
describe('with default values', () => {
|
|
6
|
-
describe('works with same dates', () => {
|
|
7
|
-
it('outputs `now`', () => {
|
|
8
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 0), new Date(1986, 3, 5, 10, 30, 0));
|
|
9
|
-
expect(result).toBe('now');
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe('works with single second', () => {
|
|
14
|
-
it('works with future', () => {
|
|
15
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 1), new Date(1986, 3, 5, 10, 30, 0));
|
|
16
|
-
expect(result).toBe('in 1 second');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('works with past', () => {
|
|
20
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 0), new Date(1986, 3, 5, 10, 30, 1));
|
|
21
|
-
expect(result).toBe('1 second ago');
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('works with multiple seconds', () => {
|
|
26
|
-
it('works with future', () => {
|
|
27
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 59), new Date(1986, 3, 5, 10, 30, 0));
|
|
28
|
-
expect(result).toBe('in 59 seconds');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('works with past', () => {
|
|
32
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 0), new Date(1986, 3, 5, 10, 30, 59));
|
|
33
|
-
expect(result).toBe('59 seconds ago');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('works with single minute', () => {
|
|
38
|
-
it('works with future', () => {
|
|
39
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 59), new Date(1986, 3, 5, 10, 29, 59));
|
|
40
|
-
expect(result).toBe('in 1 minute');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('works with future with over a minute', () => {
|
|
44
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30), new Date(1986, 3, 5, 10, 28, 10));
|
|
45
|
-
expect(result).toBe('in 1 minute');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('works with past', () => {
|
|
49
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 29, 59), new Date(1986, 3, 5, 10, 30, 59));
|
|
50
|
-
expect(result).toBe('1 minute ago');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('works with past with over a minute', () => {
|
|
54
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 28, 10), new Date(1986, 3, 5, 10, 30));
|
|
55
|
-
expect(result).toBe('1 minute ago');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('works with multiple minutes', () => {
|
|
60
|
-
it('works with future', () => {
|
|
61
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30), new Date(1986, 3, 5, 10, 28));
|
|
62
|
-
expect(result).toBe('in 2 minutes');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('works with past', () => {
|
|
66
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 28), new Date(1986, 3, 5, 10, 30));
|
|
67
|
-
expect(result).toBe('2 minutes ago');
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('works with 60 seconds', () => {
|
|
72
|
-
it('works with future', () => {
|
|
73
|
-
const result = intlFormatDistance(new Date(1986, 3, 4, 11, 30, 0), new Date(1986, 3, 4, 10, 30, 0));
|
|
74
|
-
expect(result).toBe('in 1 hour');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('works with past', () => {
|
|
78
|
-
const result = intlFormatDistance(new Date(1986, 3, 4, 10, 30, 0), new Date(1986, 3, 4, 11, 30, 0));
|
|
79
|
-
expect(result).toBe('1 hour ago');
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('works with single hour', () => {
|
|
84
|
-
it('works with future', () => {
|
|
85
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10), new Date(1986, 3, 5, 9));
|
|
86
|
-
expect(result).toBe('in 1 hour');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('works with future', () => {
|
|
90
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30), new Date(1986, 3, 5, 9));
|
|
91
|
-
expect(result).toBe('in 1 hour');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('works with past', () => {
|
|
95
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 9), new Date(1986, 3, 5, 10));
|
|
96
|
-
expect(result).toBe('1 hour ago');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('works with past with over an hour', () => {
|
|
100
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 9), new Date(1986, 3, 5, 10, 30));
|
|
101
|
-
expect(result).toBe('1 hour ago');
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe('works with multiple hours', () => {
|
|
106
|
-
it('works with future', () => {
|
|
107
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10), new Date(1986, 3, 5, 8));
|
|
108
|
-
expect(result).toBe('in 2 hours');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('works with future with extra minutes', () => {
|
|
112
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30), new Date(1986, 3, 5, 8));
|
|
113
|
-
expect(result).toBe('in 2 hours');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('works with past', () => {
|
|
117
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 8), new Date(1986, 3, 5, 10));
|
|
118
|
-
expect(result).toBe('2 hours ago');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('works with past with extra minutes', () => {
|
|
122
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 8), new Date(1986, 3, 5, 10));
|
|
123
|
-
expect(result).toBe('2 hours ago');
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('works with single day', () => {
|
|
128
|
-
it('works with future', () => {
|
|
129
|
-
const result = intlFormatDistance(new Date(1986, 3, 6, 22), new Date(1986, 3, 5, 22));
|
|
130
|
-
expect(result).toBe('tomorrow');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('works with past', () => {
|
|
134
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 22), new Date(1986, 3, 6, 22));
|
|
135
|
-
expect(result).toBe('yesterday');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('works with past with an extra hour', () => {
|
|
139
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 22), new Date(1986, 3, 6, 22, 5));
|
|
140
|
-
expect(result).toBe('yesterday');
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe('works with multiple days', () => {
|
|
145
|
-
it('works with future', () => {
|
|
146
|
-
const result = intlFormatDistance(new Date(1986, 3, 6, 22), new Date(1986, 3, 4, 22));
|
|
147
|
-
expect(result).toBe('in 2 days');
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('works with past', () => {
|
|
151
|
-
const result = intlFormatDistance(new Date(1986, 3, 4, 22), new Date(1986, 3, 6, 22));
|
|
152
|
-
expect(result).toBe('2 days ago');
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
describe('works with single week', () => {
|
|
157
|
-
it('works with future', () => {
|
|
158
|
-
const result = intlFormatDistance(new Date(1986, 3, 10, 22), new Date(1986, 3, 3, 22));
|
|
159
|
-
expect(result).toBe('next week');
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('works with future with more than a week', () => {
|
|
163
|
-
const result = intlFormatDistance(new Date(1986, 3, 11, 22), new Date(1986, 3, 3, 22));
|
|
164
|
-
expect(result).toBe('next week');
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('works with past', () => {
|
|
168
|
-
const result = intlFormatDistance(new Date(1986, 3, 3, 22), new Date(1986, 3, 10, 22));
|
|
169
|
-
expect(result).toBe('last week');
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('works with past with more than a week', () => {
|
|
173
|
-
const result = intlFormatDistance(new Date(1986, 3, 3, 22), new Date(1986, 3, 11, 22));
|
|
174
|
-
expect(result).toBe('last week');
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe('works with multiple weeks', () => {
|
|
179
|
-
it('works with future', () => {
|
|
180
|
-
const result = intlFormatDistance(new Date(1986, 3, 15), new Date(1986, 3, 1));
|
|
181
|
-
expect(result).toBe('in 2 weeks');
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('works with future with more than 2 weeks', () => {
|
|
185
|
-
const result = intlFormatDistance(new Date(1986, 3, 17), new Date(1986, 3, 1));
|
|
186
|
-
expect(result).toBe('in 2 weeks');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('works with past', () => {
|
|
190
|
-
const result = intlFormatDistance(new Date(1986, 3, 1), new Date(1986, 3, 15));
|
|
191
|
-
expect(result).toBe('2 weeks ago');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('works with past with more than 2 weeks', () => {
|
|
195
|
-
const result = intlFormatDistance(new Date(1986, 3, 1), new Date(1986, 3, 17));
|
|
196
|
-
expect(result).toBe('2 weeks ago');
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
describe('works with single month', () => {
|
|
201
|
-
it('works with future', () => {
|
|
202
|
-
const result = intlFormatDistance(new Date(1986, 4, 2), new Date(1986, 3, 1));
|
|
203
|
-
expect(result).toBe('next month');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('works with future with more than a month', () => {
|
|
207
|
-
const result = intlFormatDistance(new Date(1986, 4, 22), new Date(1986, 3, 1));
|
|
208
|
-
expect(result).toBe('next month');
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('works with past', () => {
|
|
212
|
-
const result = intlFormatDistance(new Date(1986, 3, 1), new Date(1986, 4, 2));
|
|
213
|
-
expect(result).toBe('last month');
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('works with past with more than a month', () => {
|
|
217
|
-
const result = intlFormatDistance(new Date(1986, 3, 1), new Date(1986, 4, 22));
|
|
218
|
-
expect(result).toBe('last month');
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
describe('works with single quarter', () => {
|
|
223
|
-
it('works with future', () => {
|
|
224
|
-
const result = intlFormatDistance(new Date(1986, 5, 2), new Date(1986, 1, 1));
|
|
225
|
-
expect(result).toBe('next quarter');
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('works with future with more than a quarter', () => {
|
|
229
|
-
const result = intlFormatDistance(new Date(1986, 5, 22), new Date(1986, 1, 1));
|
|
230
|
-
expect(result).toBe('next quarter');
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('works with past', () => {
|
|
234
|
-
const result = intlFormatDistance(new Date(1986, 1, 1), new Date(1986, 5, 2));
|
|
235
|
-
expect(result).toBe('last quarter');
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('works with past with more than a quarter', () => {
|
|
239
|
-
const result = intlFormatDistance(new Date(1986, 1, 1), new Date(1986, 5, 22));
|
|
240
|
-
expect(result).toBe('last quarter');
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('works with multiple quarters', () => {
|
|
245
|
-
it('works with future', () => {
|
|
246
|
-
const result = intlFormatDistance(new Date(1986, 6, 2), new Date(1986, 1, 1));
|
|
247
|
-
expect(result).toBe('in 2 quarters');
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('works with future with more that X quarters', () => {
|
|
251
|
-
const result = intlFormatDistance(new Date(1986, 6, 22), new Date(1986, 1, 1));
|
|
252
|
-
expect(result).toBe('in 2 quarters');
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it('works with past', () => {
|
|
256
|
-
const result = intlFormatDistance(new Date(1986, 1, 1), new Date(1986, 6, 2));
|
|
257
|
-
expect(result).toBe('2 quarters ago');
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it('works with past with more that X quarters', () => {
|
|
261
|
-
const result = intlFormatDistance(new Date(1986, 1, 1), new Date(1986, 6, 22));
|
|
262
|
-
expect(result).toBe('2 quarters ago');
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
describe('works with single year', () => {
|
|
267
|
-
it('works with future', () => {
|
|
268
|
-
const result = intlFormatDistance(new Date(1987, 1, 2), new Date(1986, 1, 1));
|
|
269
|
-
expect(result).toBe('next year');
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('works with future with more that a year', () => {
|
|
273
|
-
const result = intlFormatDistance(new Date(1987, 10, 2), new Date(1986, 1, 1));
|
|
274
|
-
expect(result).toBe('next year');
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('works with past', () => {
|
|
278
|
-
const result = intlFormatDistance(new Date(1986, 1, 1), new Date(1987, 1, 2));
|
|
279
|
-
expect(result).toBe('last year');
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('works with past with more than a year', () => {
|
|
283
|
-
const result = intlFormatDistance(new Date(1986, 1, 1), new Date(1987, 10, 2));
|
|
284
|
-
expect(result).toBe('last year');
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
describe('works with multiple years', () => {
|
|
289
|
-
it('works with future', () => {
|
|
290
|
-
const result = intlFormatDistance(new Date(1988, 1, 1), new Date(1986, 1, 1));
|
|
291
|
-
expect(result).toBe('in 2 years');
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('works with future with x years', () => {
|
|
295
|
-
const result = intlFormatDistance(new Date(2088, 1, 1), new Date(1986, 1, 1));
|
|
296
|
-
expect(result).toBe('in 102 years');
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('works with past', () => {
|
|
300
|
-
const result = intlFormatDistance(new Date(1986, 1, 1), new Date(1988, 1, 1));
|
|
301
|
-
expect(result).toBe('2 years ago');
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
it('works with past with x years', () => {
|
|
305
|
-
const result = intlFormatDistance(new Date(1988, 1, 1), new Date(2086, 1, 1));
|
|
306
|
-
expect(result).toBe('98 years ago');
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
describe('with options', () => {
|
|
312
|
-
describe('unit option', () => {
|
|
313
|
-
describe('seconds', () => {
|
|
314
|
-
it('works with future with seconds', () => {
|
|
315
|
-
const result = intlFormatDistance(new Date(1987, 3, 4, 10, 31, 30), new Date(1987, 3, 4, 10, 30, 0), {
|
|
316
|
-
unit: 'second',
|
|
317
|
-
});
|
|
318
|
-
expect(result).toBe('in 90 seconds');
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('works with past with seconds', () => {
|
|
322
|
-
const result = intlFormatDistance(new Date(1987, 3, 4, 10, 30, 0), new Date(1987, 3, 4, 10, 31, 30), {
|
|
323
|
-
unit: 'second',
|
|
324
|
-
});
|
|
325
|
-
expect(result).toBe('90 seconds ago');
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it('works with future with quarters', () => {
|
|
329
|
-
const result = intlFormatDistance(new Date(1987, 6, 4, 10, 30, 0), new Date(1986, 3, 4, 10, 30, 0), {
|
|
330
|
-
unit: 'quarter',
|
|
331
|
-
});
|
|
332
|
-
expect(result).toBe('in 5 quarters');
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
describe('minutes', () => {
|
|
337
|
-
it('works with future', () => {
|
|
338
|
-
const result = intlFormatDistance(new Date(1986, 3, 4, 11, 30, 0), new Date(1986, 3, 4, 10, 30, 0), {
|
|
339
|
-
unit: 'minute',
|
|
340
|
-
});
|
|
341
|
-
expect(result).toBe('in 60 minutes');
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
it('works with the past', () => {
|
|
345
|
-
const result = intlFormatDistance(new Date(1986, 3, 4, 10, 30, 0), new Date(1986, 3, 4, 11, 30, 0), {
|
|
346
|
-
unit: 'minute',
|
|
347
|
-
});
|
|
348
|
-
expect(result).toBe('60 minutes ago');
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
describe('hours', () => {
|
|
353
|
-
it('works the future', () => {
|
|
354
|
-
const result = intlFormatDistance(
|
|
355
|
-
new Date(1986, 3, 4, 11, 30, 0),
|
|
356
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
357
|
-
|
|
358
|
-
{ unit: 'hour' },
|
|
359
|
-
);
|
|
360
|
-
expect(result).toBe('in 1 hour');
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it('works with the past', () => {
|
|
364
|
-
const result = intlFormatDistance(
|
|
365
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
366
|
-
new Date(1986, 3, 4, 11, 30, 0),
|
|
367
|
-
|
|
368
|
-
{ unit: 'hour' },
|
|
369
|
-
);
|
|
370
|
-
expect(result).toBe('1 hour ago');
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
describe('single day', () => {
|
|
375
|
-
it('works with the future', () => {
|
|
376
|
-
const result = intlFormatDistance(new Date(1987, 3, 4, 11, 30, 0), new Date(1987, 3, 4, 10, 30, 0), {
|
|
377
|
-
unit: 'day',
|
|
378
|
-
});
|
|
379
|
-
expect(result).toBe('today');
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
it('works with the past', () => {
|
|
383
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 0), new Date(1986, 3, 4, 10, 30, 0));
|
|
384
|
-
expect(result).toBe('tomorrow');
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
describe('multiple days', () => {
|
|
389
|
-
it('works with the future', () => {
|
|
390
|
-
const result = intlFormatDistance(new Date(1987, 3, 5, 10, 30, 0), new Date(1986, 3, 4, 10, 30, 0), {
|
|
391
|
-
unit: 'day',
|
|
392
|
-
});
|
|
393
|
-
expect(result).toBe('in 366 days');
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it('works with the past', () => {
|
|
397
|
-
const result = intlFormatDistance(
|
|
398
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
399
|
-
new Date(1987, 3, 5, 10, 30, 0),
|
|
400
|
-
|
|
401
|
-
{ unit: 'day' },
|
|
402
|
-
);
|
|
403
|
-
expect(result).toBe('366 days ago');
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
describe('single weeks', () => {
|
|
408
|
-
it('works with the future', () => {
|
|
409
|
-
const result = intlFormatDistance(new Date(1987, 3, 11, 10, 30, 0), new Date(1987, 3, 4, 10, 30, 0), {
|
|
410
|
-
unit: 'week',
|
|
411
|
-
});
|
|
412
|
-
expect(result).toBe('next week');
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
it('works with the past', () => {
|
|
416
|
-
const result = intlFormatDistance(new Date(1987, 3, 4, 10, 30, 0), new Date(1987, 3, 11, 10, 30, 0), {
|
|
417
|
-
unit: 'week',
|
|
418
|
-
});
|
|
419
|
-
expect(result).toBe('last week');
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
describe('multiple weeks', () => {
|
|
424
|
-
it('works with the future', () => {
|
|
425
|
-
const result = intlFormatDistance(new Date(1987, 3, 6, 10, 30, 0), new Date(1986, 3, 4, 10, 30, 0), {
|
|
426
|
-
unit: 'week',
|
|
427
|
-
});
|
|
428
|
-
expect(result).toBe('in 53 weeks');
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
it('works with the past', () => {
|
|
432
|
-
const result = intlFormatDistance(
|
|
433
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
434
|
-
new Date(1987, 3, 6, 10, 30, 0),
|
|
435
|
-
|
|
436
|
-
{ unit: 'week' },
|
|
437
|
-
);
|
|
438
|
-
expect(result).toBe('53 weeks ago');
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
describe('numeric option', () => {
|
|
444
|
-
describe('works with weeks', () => {
|
|
445
|
-
it('works with past', () => {
|
|
446
|
-
const result = intlFormatDistance(new Date(1986, 3, 3, 22), new Date(1986, 3, 10, 22), { numeric: 'always' });
|
|
447
|
-
expect(result).toBe('1 week ago');
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
it('works with future', () => {
|
|
451
|
-
const result = intlFormatDistance(new Date(1986, 3, 10, 22), new Date(1986, 3, 3, 22), { numeric: 'always' });
|
|
452
|
-
expect(result).toBe('in 1 week');
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
it('works with days', () => {
|
|
457
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 0), new Date(1986, 3, 4, 10, 30, 0), {
|
|
458
|
-
numeric: 'always',
|
|
459
|
-
});
|
|
460
|
-
expect(result).toBe('in 1 day');
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
it('works with the same dates', () => {
|
|
464
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 10, 30, 0), new Date(1986, 3, 5, 10, 30, 0), {
|
|
465
|
-
numeric: 'auto',
|
|
466
|
-
});
|
|
467
|
-
expect(result).toBe('now');
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
describe('locale option', () => {
|
|
472
|
-
describe('locale', () => {
|
|
473
|
-
it('allows to set Spanish locale', () => {
|
|
474
|
-
const result = intlFormatDistance(new Date(1986, 4, 4, 10, 30, 0), new Date(1985, 4, 4, 10, 30, 0), {
|
|
475
|
-
locale: 'es',
|
|
476
|
-
});
|
|
477
|
-
expect(result).toBe('el próximo año');
|
|
478
|
-
});
|
|
479
|
-
});
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
describe('style option', () => {
|
|
483
|
-
it('works with years', () => {
|
|
484
|
-
const result = intlFormatDistance(new Date(1986, 4, 4, 10, 30, 0), new Date(1985, 4, 4, 10, 30, 0), {
|
|
485
|
-
style: 'long',
|
|
486
|
-
});
|
|
487
|
-
expect(result).toBe('next year');
|
|
488
|
-
});
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
describe('unit and locale options', () => {
|
|
492
|
-
it('works with multiple options', () => {
|
|
493
|
-
const result = intlFormatDistance(new Date(1986, 3, 5, 11, 30, 0), new Date(1986, 3, 5, 10, 30, 0), {
|
|
494
|
-
unit: 'minute',
|
|
495
|
-
locale: 'de',
|
|
496
|
-
});
|
|
497
|
-
expect(result).toBe('in 60 Minuten');
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
describe('edge cases', () => {
|
|
502
|
-
it('falls back to { numeric: always }', () => {
|
|
503
|
-
const result = intlFormatDistance(new Date(1985, 4, 5, 10, 30, 0), new Date(1985, 4, 4, 10, 30, 0), {
|
|
504
|
-
style: 'long',
|
|
505
|
-
numeric: 'auto',
|
|
506
|
-
});
|
|
507
|
-
expect(result).toBe('tomorrow');
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
it('handles dates before 100 AD', () => {
|
|
511
|
-
const result = intlFormatDistance(new Date(1, 3, 4, 11, 30, 0), new Date(1, 3, 4, 10, 30, 0), {
|
|
512
|
-
unit: 'minute',
|
|
513
|
-
});
|
|
514
|
-
expect(result).toBe('in 60 minutes');
|
|
515
|
-
});
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
describe('errors', () => {
|
|
519
|
-
it('checks the first date', () => {
|
|
520
|
-
expect(intlFormatDistance.bind(null, new Date(NaN), new Date(1986, 3, 4, 10, 30, 0))).toThrow(RangeError);
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
it('checks the second date', () => {
|
|
524
|
-
expect(intlFormatDistance.bind(null, new Date(1986, 3, 4, 10, 30, 0), new Date(NaN))).toThrow(RangeError);
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
it('checks both dates', () => {
|
|
528
|
-
expect(intlFormatDistance.bind(null, new Date(NaN), new Date(NaN))).toThrow(RangeError);
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
it('checks unit', () => {
|
|
532
|
-
expect(
|
|
533
|
-
intlFormatDistance.bind(
|
|
534
|
-
null,
|
|
535
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
536
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
537
|
-
// @ts-expect-error - We're testing wrong value
|
|
538
|
-
{ unit: 'wrongValue' },
|
|
539
|
-
),
|
|
540
|
-
).toThrow(RangeError);
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
it('checks locale', () => {
|
|
544
|
-
expect(
|
|
545
|
-
intlFormatDistance.bind(null, new Date(1986, 3, 4, 10, 30, 0), new Date(1986, 3, 4, 10, 30, 0), {
|
|
546
|
-
locale: 'wrongValue',
|
|
547
|
-
}),
|
|
548
|
-
).toThrow(RangeError);
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
it('checks localeMatcher', () => {
|
|
552
|
-
expect(
|
|
553
|
-
intlFormatDistance.bind(
|
|
554
|
-
null,
|
|
555
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
556
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
557
|
-
// @ts-expect-error - We're testing wrong value
|
|
558
|
-
{ localeMatcher: 'wrongValue' },
|
|
559
|
-
),
|
|
560
|
-
).toThrow(RangeError);
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
it('checks numeric', () => {
|
|
564
|
-
expect(
|
|
565
|
-
intlFormatDistance.bind(
|
|
566
|
-
null,
|
|
567
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
568
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
569
|
-
// @ts-expect-error - We're testing wrong value
|
|
570
|
-
{ numeric: 'wrongValue' },
|
|
571
|
-
),
|
|
572
|
-
).toThrow(RangeError);
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
it('checks style', () => {
|
|
576
|
-
expect(
|
|
577
|
-
intlFormatDistance.bind(
|
|
578
|
-
null,
|
|
579
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
580
|
-
new Date(1986, 3, 4, 10, 30, 0),
|
|
581
|
-
// @ts-expect-error - We're testing wrong value
|
|
582
|
-
{ style: 'wrongValue' },
|
|
583
|
-
),
|
|
584
|
-
).toThrow(RangeError);
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isAfter } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isAfter', () => {
|
|
5
|
-
it('returns true if the first date is after the second one', () => {
|
|
6
|
-
const result = isAfter(new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the first date is before the second one', () => {
|
|
11
|
-
const result = isAfter(new Date(1987, 1 /* Feb */, 11), new Date(1989, 6 /* Jul */, 10));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('returns false if the first date is equal to the second one', () => {
|
|
16
|
-
const result = isAfter(new Date(1989, 6 /* Jul */, 10), new Date(1989, 6 /* Jul */, 10));
|
|
17
|
-
expect(result).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('accepts a timestamp', () => {
|
|
21
|
-
const result = isAfter(new Date(1989, 6 /* Jul */, 10).getTime(), new Date(1987, 1 /* Feb */, 11).getTime());
|
|
22
|
-
expect(result).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
26
|
-
const result = isAfter(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
31
|
-
const result = isAfter(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
36
|
-
const result = isAfter(new Date(NaN), new Date(NaN));
|
|
37
|
-
expect(result).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isBefore } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isBefore', () => {
|
|
5
|
-
it('returns true if the first date is before the second one', () => {
|
|
6
|
-
const result = isBefore(new Date(1987, 1 /* Feb */, 11), new Date(1989, 6 /* Jul */, 10));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the first date is after the second one', () => {
|
|
11
|
-
const result = isBefore(new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('returns false if the first date is equal to the second one', () => {
|
|
16
|
-
const result = isBefore(new Date(1989, 6 /* Jul */, 10), new Date(1989, 6 /* Jul */, 10));
|
|
17
|
-
expect(result).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('accepts a timestamp', () => {
|
|
21
|
-
const result = isBefore(new Date(1987, 1 /* Feb */, 11).getTime(), new Date(1989, 6 /* Jul */, 10).getTime());
|
|
22
|
-
expect(result).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
26
|
-
const result = isBefore(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
31
|
-
const result = isBefore(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
36
|
-
const result = isBefore(new Date(NaN), new Date(NaN));
|
|
37
|
-
expect(result).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
});
|