@@ -219,6 +219,49 @@ test("Test - Weekday casual `Next` guessing", function () {
219
219
}
220
220
} ) ;
221
221
222
+ test ( "Test - Casual 'weekend' and 'weekday'" , ( ) => {
223
+ {
224
+ const refDateOnFriday = new Date ( 2024 , 10 - 1 , 18 , 12 , 0 ) ;
225
+ testSingleCase ( chrono . casual , "last weekend" , refDateOnFriday , ( result , text ) => {
226
+ expect ( result . text ) . toBe ( text ) ;
227
+ expect ( result . start ) . toBeDate ( new Date ( 2024 , 10 - 1 , 13 , 12 ) ) ; // Sunday
228
+ } ) ;
229
+ testSingleCase ( chrono . casual , "this weekend" , refDateOnFriday , ( result , text ) => {
230
+ expect ( result . text ) . toBe ( text ) ;
231
+ expect ( result . start ) . toBeDate ( new Date ( 2024 , 10 - 1 , 19 , 12 ) ) ; // Saturday
232
+ } ) ;
233
+ testSingleCase ( chrono . casual , "next weekend" , refDateOnFriday , ( result , text ) => {
234
+ expect ( result . text ) . toBe ( text ) ;
235
+ expect ( result . start ) . toBeDate ( new Date ( 2024 , 10 - 1 , 26 , 12 ) ) ; // Saturday
236
+ } ) ;
237
+ }
238
+ } ) ;
239
+
240
+ test ( "Test - Casual 'weekday' mentioning" , ( ) => {
241
+ {
242
+ const refDateOnFriday = new Date ( 2024 , 10 - 1 , 18 , 12 , 0 ) ;
243
+ testSingleCase ( chrono . casual , "last weekday" , refDateOnFriday , ( result , text ) => {
244
+ expect ( result . text ) . toBe ( text ) ;
245
+ expect ( result . start ) . toBeDate ( new Date ( 2024 , 10 - 1 , 17 , 12 ) ) ; // Thursday
246
+ } ) ;
247
+ testSingleCase ( chrono . casual , "next weekday" , refDateOnFriday , ( result , text ) => {
248
+ expect ( result . text ) . toBe ( text ) ;
249
+ expect ( result . start ) . toBeDate ( new Date ( 2024 , 10 - 1 , 21 , 12 ) ) ; // Monday
250
+ } ) ;
251
+ }
252
+ {
253
+ const refDateOnSaturday = new Date ( 2024 , 10 - 1 , 19 , 12 , 0 ) ;
254
+ testSingleCase ( chrono . casual , "last weekday" , refDateOnSaturday , ( result , text ) => {
255
+ expect ( result . text ) . toBe ( text ) ;
256
+ expect ( result . start ) . toBeDate ( new Date ( 2024 , 10 - 1 , 18 , 12 ) ) ; // Friday
257
+ } ) ;
258
+ testSingleCase ( chrono . casual , "next weekday" , refDateOnSaturday , ( result , text ) => {
259
+ expect ( result . text ) . toBe ( text ) ;
260
+ expect ( result . start ) . toBeDate ( new Date ( 2024 , 10 - 1 , 21 , 12 ) ) ; // Monday
261
+ } ) ;
262
+ }
263
+ } ) ;
264
+
222
265
test ( "Test - Weekday With Casual Time" , function ( ) {
223
266
testSingleCase ( chrono . casual , "Lets meet on Tuesday morning" , new Date ( 2015 , 3 , 18 ) , ( result ) => {
224
267
expect ( result . index ) . toBe ( 10 ) ;
0 commit comments