@@ -174,6 +174,48 @@ test("Test - The normal within expression", () => {
174
174
} ) ;
175
175
} ) ;
176
176
177
+ test ( "Test - The within expression with multiple time units" , function ( ) {
178
+ testSingleCase ( chrono , "set a timer for 5 minutes 30 seconds" , new Date ( 2012 , 7 , 10 , 12 , 14 ) , ( result ) => {
179
+ expect ( result . index ) . toBe ( 12 ) ;
180
+ expect ( result . text ) . toBe ( "for 5 minutes 30 seconds" ) ;
181
+
182
+ expect ( result . start ) . toBeDate ( new Date ( 2012 , 7 , 10 , 12 , 19 , 30 ) ) ;
183
+ } ) ;
184
+
185
+ testSingleCase ( chrono , "set a timer for 5 minutes, 30 seconds" , new Date ( 2012 , 7 , 10 , 12 , 14 ) , ( result ) => {
186
+ expect ( result . index ) . toBe ( 12 ) ;
187
+ expect ( result . text ) . toBe ( "for 5 minutes, 30 seconds" ) ;
188
+
189
+ expect ( result . start ) . toBeDate ( new Date ( 2012 , 7 , 10 , 12 , 19 , 30 ) ) ;
190
+ } ) ;
191
+
192
+ testSingleCase ( chrono , "set a timer for 1 hour, 5 minutes, 30 seconds" , new Date ( 2012 , 7 , 10 , 12 , 14 ) , ( result ) => {
193
+ expect ( result . index ) . toBe ( 12 ) ;
194
+ expect ( result . text ) . toBe ( "for 1 hour, 5 minutes, 30 seconds" ) ;
195
+
196
+ expect ( result . start ) . toBeDate ( new Date ( 2012 , 7 , 10 , 13 , 19 , 30 ) ) ;
197
+ } ) ;
198
+
199
+ testSingleCase ( chrono , "set a timer for 5 minutes and 30 seconds" , new Date ( 2012 , 7 , 10 , 12 , 14 ) , ( result ) => {
200
+ expect ( result . index ) . toBe ( 12 ) ;
201
+ expect ( result . text ) . toBe ( "for 5 minutes and 30 seconds" ) ;
202
+
203
+ expect ( result . start ) . toBeDate ( new Date ( 2012 , 7 , 10 , 12 , 19 , 30 ) ) ;
204
+ } ) ;
205
+
206
+ testSingleCase (
207
+ chrono ,
208
+ "set a timer for 1 hour, 5 minutes, and 30 seconds" ,
209
+ new Date ( 2012 , 7 , 10 , 12 , 14 ) ,
210
+ ( result ) => {
211
+ expect ( result . index ) . toBe ( 12 ) ;
212
+ expect ( result . text ) . toBe ( "for 1 hour, 5 minutes, and 30 seconds" ) ;
213
+
214
+ expect ( result . start ) . toBeDate ( new Date ( 2012 , 7 , 10 , 13 , 19 , 30 ) ) ;
215
+ }
216
+ ) ;
217
+ } ) ;
218
+
177
219
test ( "Test - The within expression with certain keywords" , ( ) => {
178
220
testSingleCase ( chrono , "In about 5 hours" , new Date ( 2012 , 8 - 1 , 10 , 12 , 49 ) , ( result , text ) => {
179
221
expect ( result . text ) . toBe ( text ) ;
0 commit comments