@dereekb/vitest 13.4.0 → 13.4.2
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/package.json +1 -1
- package/src/lib/matcher.date.d.ts +20 -20
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MatcherState, SyncExpectationResult } from '@vitest/expect';
|
|
2
2
|
/**
|
|
3
3
|
* Utility type that extracts the `expected` parameter from a date matcher function, producing the consumer-facing matcher signature.
|
|
4
4
|
*
|
|
5
5
|
* Used by {@link AllDateMatchers} to map internal matcher implementations to their public `expect().toBe*()` signatures.
|
|
6
6
|
*/
|
|
7
|
-
export type DateMatcherTypeWithExpected<T extends (this: MatcherState, input: Date, expected: Date) =>
|
|
7
|
+
export type DateMatcherTypeWithExpected<T extends (this: MatcherState, input: Date, expected: Date) => SyncExpectationResult> = T extends (this: MatcherState, input: any, expected: infer B) => SyncExpectationResult ? (expected: B) => SyncExpectationResult : never;
|
|
8
8
|
/**
|
|
9
9
|
* Utility type that strips the `input` parameter from a date matcher function, producing a zero-argument consumer-facing matcher signature.
|
|
10
10
|
*
|
|
11
11
|
* Used by {@link AllDateMatchers} for day-of-week matchers like `toBeMonday()`.
|
|
12
12
|
*/
|
|
13
|
-
export type DateMatcherTypeWithoutExpected<T extends (this: MatcherState, input: Date) =>
|
|
13
|
+
export type DateMatcherTypeWithoutExpected<T extends (this: MatcherState, input: Date) => SyncExpectationResult> = T extends (this: MatcherState, input: any) => SyncExpectationResult ? () => SyncExpectationResult : never;
|
|
14
14
|
/**
|
|
15
15
|
* Augmented matcher interface providing date comparison and day-of-week assertion methods for Vitest.
|
|
16
16
|
*
|
|
@@ -44,7 +44,7 @@ interface AllDateMatchers {
|
|
|
44
44
|
* @param expected - The date to compare against
|
|
45
45
|
* @returns Matcher result with a descriptive message on failure
|
|
46
46
|
*/
|
|
47
|
-
declare function toBeBefore(this: MatcherState, received: Date, expected: Date):
|
|
47
|
+
declare function toBeBefore(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
48
48
|
/**
|
|
49
49
|
* Asserts that the received date is chronologically after the expected date.
|
|
50
50
|
*
|
|
@@ -52,7 +52,7 @@ declare function toBeBefore(this: MatcherState, received: Date, expected: Date):
|
|
|
52
52
|
* @param expected - The date to compare against
|
|
53
53
|
* @returns Matcher result with a descriptive message on failure
|
|
54
54
|
*/
|
|
55
|
-
declare function toBeAfter(this: MatcherState, received: Date, expected: Date):
|
|
55
|
+
declare function toBeAfter(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
56
56
|
/**
|
|
57
57
|
* Asserts that the received date falls within the same calendar second as the expected date.
|
|
58
58
|
*
|
|
@@ -60,7 +60,7 @@ declare function toBeAfter(this: MatcherState, received: Date, expected: Date):
|
|
|
60
60
|
* @param expected - The date to compare against
|
|
61
61
|
* @returns Matcher result with a descriptive message on failure
|
|
62
62
|
*/
|
|
63
|
-
declare function toBeSameSecondAs(this: MatcherState, received: Date, expected: Date):
|
|
63
|
+
declare function toBeSameSecondAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
64
64
|
/**
|
|
65
65
|
* Asserts that the received date falls within the same calendar minute as the expected date.
|
|
66
66
|
*
|
|
@@ -68,7 +68,7 @@ declare function toBeSameSecondAs(this: MatcherState, received: Date, expected:
|
|
|
68
68
|
* @param expected - The date to compare against
|
|
69
69
|
* @returns Matcher result with a descriptive message on failure
|
|
70
70
|
*/
|
|
71
|
-
declare function toBeSameMinuteAs(this: MatcherState, received: Date, expected: Date):
|
|
71
|
+
declare function toBeSameMinuteAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
72
72
|
/**
|
|
73
73
|
* Asserts that the received date falls within the same calendar hour as the expected date.
|
|
74
74
|
*
|
|
@@ -76,7 +76,7 @@ declare function toBeSameMinuteAs(this: MatcherState, received: Date, expected:
|
|
|
76
76
|
* @param expected - The date to compare against
|
|
77
77
|
* @returns Matcher result with a descriptive message on failure
|
|
78
78
|
*/
|
|
79
|
-
declare function toBeSameHourAs(this: MatcherState, received: Date, expected: Date):
|
|
79
|
+
declare function toBeSameHourAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
80
80
|
/**
|
|
81
81
|
* Asserts that the received date falls on the same calendar day as the expected date.
|
|
82
82
|
*
|
|
@@ -84,7 +84,7 @@ declare function toBeSameHourAs(this: MatcherState, received: Date, expected: Da
|
|
|
84
84
|
* @param expected - The date to compare against
|
|
85
85
|
* @returns Matcher result with a descriptive message on failure
|
|
86
86
|
*/
|
|
87
|
-
declare function toBeSameDayAs(this: MatcherState, received: Date, expected: Date):
|
|
87
|
+
declare function toBeSameDayAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
88
88
|
/**
|
|
89
89
|
* Asserts that the received date falls within the same calendar week as the expected date.
|
|
90
90
|
*
|
|
@@ -92,7 +92,7 @@ declare function toBeSameDayAs(this: MatcherState, received: Date, expected: Dat
|
|
|
92
92
|
* @param expected - The date to compare against
|
|
93
93
|
* @returns Matcher result with a descriptive message on failure
|
|
94
94
|
*/
|
|
95
|
-
declare function toBeSameWeekAs(this: MatcherState, received: Date, expected: Date):
|
|
95
|
+
declare function toBeSameWeekAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
96
96
|
/**
|
|
97
97
|
* Asserts that the received date falls within the same calendar month as the expected date.
|
|
98
98
|
*
|
|
@@ -100,7 +100,7 @@ declare function toBeSameWeekAs(this: MatcherState, received: Date, expected: Da
|
|
|
100
100
|
* @param expected - The date to compare against
|
|
101
101
|
* @returns Matcher result with a descriptive message on failure
|
|
102
102
|
*/
|
|
103
|
-
declare function toBeSameMonthAs(this: MatcherState, received: Date, expected: Date):
|
|
103
|
+
declare function toBeSameMonthAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
104
104
|
/**
|
|
105
105
|
* Asserts that the received date falls within the same fiscal quarter as the expected date.
|
|
106
106
|
*
|
|
@@ -108,7 +108,7 @@ declare function toBeSameMonthAs(this: MatcherState, received: Date, expected: D
|
|
|
108
108
|
* @param expected - The date to compare against
|
|
109
109
|
* @returns Matcher result with a descriptive message on failure
|
|
110
110
|
*/
|
|
111
|
-
declare function toBeSameQuarterAs(this: MatcherState, received: Date, expected: Date):
|
|
111
|
+
declare function toBeSameQuarterAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
112
112
|
/**
|
|
113
113
|
* Asserts that the received date falls within the same calendar year as the expected date.
|
|
114
114
|
*
|
|
@@ -116,56 +116,56 @@ declare function toBeSameQuarterAs(this: MatcherState, received: Date, expected:
|
|
|
116
116
|
* @param expected - The date to compare against
|
|
117
117
|
* @returns Matcher result with a descriptive message on failure
|
|
118
118
|
*/
|
|
119
|
-
declare function toBeSameYearAs(this: MatcherState, received: Date, expected: Date):
|
|
119
|
+
declare function toBeSameYearAs(this: MatcherState, received: Date, expected: Date): SyncExpectationResult;
|
|
120
120
|
/**
|
|
121
121
|
* Asserts that the received date falls on a Monday.
|
|
122
122
|
*
|
|
123
123
|
* @param received - The date under test
|
|
124
124
|
* @returns Matcher result with a descriptive message on failure
|
|
125
125
|
*/
|
|
126
|
-
declare function toBeMonday(this: MatcherState, received: Date):
|
|
126
|
+
declare function toBeMonday(this: MatcherState, received: Date): SyncExpectationResult;
|
|
127
127
|
/**
|
|
128
128
|
* Asserts that the received date falls on a Tuesday.
|
|
129
129
|
*
|
|
130
130
|
* @param received - The date under test
|
|
131
131
|
* @returns Matcher result with a descriptive message on failure
|
|
132
132
|
*/
|
|
133
|
-
declare function toBeTuesday(this: MatcherState, received: Date):
|
|
133
|
+
declare function toBeTuesday(this: MatcherState, received: Date): SyncExpectationResult;
|
|
134
134
|
/**
|
|
135
135
|
* Asserts that the received date falls on a Wednesday.
|
|
136
136
|
*
|
|
137
137
|
* @param received - The date under test
|
|
138
138
|
* @returns Matcher result with a descriptive message on failure
|
|
139
139
|
*/
|
|
140
|
-
declare function toBeWednesday(this: MatcherState, received: Date):
|
|
140
|
+
declare function toBeWednesday(this: MatcherState, received: Date): SyncExpectationResult;
|
|
141
141
|
/**
|
|
142
142
|
* Asserts that the received date falls on a Thursday.
|
|
143
143
|
*
|
|
144
144
|
* @param received - The date under test
|
|
145
145
|
* @returns Matcher result with a descriptive message on failure
|
|
146
146
|
*/
|
|
147
|
-
declare function toBeThursday(this: MatcherState, received: Date):
|
|
147
|
+
declare function toBeThursday(this: MatcherState, received: Date): SyncExpectationResult;
|
|
148
148
|
/**
|
|
149
149
|
* Asserts that the received date falls on a Friday.
|
|
150
150
|
*
|
|
151
151
|
* @param received - The date under test
|
|
152
152
|
* @returns Matcher result with a descriptive message on failure
|
|
153
153
|
*/
|
|
154
|
-
declare function toBeFriday(this: MatcherState, received: Date):
|
|
154
|
+
declare function toBeFriday(this: MatcherState, received: Date): SyncExpectationResult;
|
|
155
155
|
/**
|
|
156
156
|
* Asserts that the received date falls on a Saturday.
|
|
157
157
|
*
|
|
158
158
|
* @param received - The date under test
|
|
159
159
|
* @returns Matcher result with a descriptive message on failure
|
|
160
160
|
*/
|
|
161
|
-
declare function toBeSaturday(this: MatcherState, received: Date):
|
|
161
|
+
declare function toBeSaturday(this: MatcherState, received: Date): SyncExpectationResult;
|
|
162
162
|
/**
|
|
163
163
|
* Asserts that the received date falls on a Sunday.
|
|
164
164
|
*
|
|
165
165
|
* @param received - The date under test
|
|
166
166
|
* @returns Matcher result with a descriptive message on failure
|
|
167
167
|
*/
|
|
168
|
-
declare function toBeSunday(this: MatcherState, received: Date):
|
|
168
|
+
declare function toBeSunday(this: MatcherState, received: Date): SyncExpectationResult;
|
|
169
169
|
/**
|
|
170
170
|
* Object containing all date matcher implementations, ready to be registered with `expect.extend()`.
|
|
171
171
|
*
|