@@ -240,6 +240,50 @@ describe('datetimepicker', function() {
240
240
241
241
// TODO: Should test the error path, but not sure what throws the error or what the message looks like.
242
242
} ) ;
243
+
244
+ describe ( 'parseDateTimeInternal' , function ( ) {
245
+ it ( 'should return only a date if there is no time component' , function ( ) {
246
+ var inputDateString = '9/11/2001' ,
247
+ expectedDate = new Date ( inputDateString ) ,
248
+ result ;
249
+
250
+ result = $ . timepicker . _util . _parseDateTimeInternal ( 'mm/dd/yy' , undefined , inputDateString , undefined , undefined ) ;
251
+
252
+ expect ( result . date ) . toEqual ( expectedDate ) ;
253
+ expect ( result . timeObj ) . toBeUndefined ( ) ;
254
+ } ) ;
255
+
256
+ it ( 'should return a date and a parsed time if a time is included' , function ( ) {
257
+ var expectedDateString = '7/4/1976' ,
258
+ expectedParsedTime = {
259
+ hour : 1 ,
260
+ minute : 23 ,
261
+ second : 45 ,
262
+ millisec : 678 ,
263
+ microsec : 0
264
+ } ,
265
+ inputDateTimeString = expectedDateString + ' '
266
+ + expectedParsedTime . hour + ':'
267
+ + expectedParsedTime . minute + ':'
268
+ + expectedParsedTime . second + '.'
269
+ + expectedParsedTime . millisec ,
270
+ expectedDate = new Date ( expectedDateString ) ,
271
+ result ;
272
+
273
+ result = $ . timepicker . _util . _parseDateTimeInternal ( 'mm/dd/yy' , 'H:m:s.l' , inputDateTimeString , undefined , undefined ) ;
274
+
275
+ expect ( result . date ) . toEqual ( expectedDate ) ;
276
+ expect ( result . timeObj ) . toEqual ( expectedParsedTime ) ;
277
+ } ) ;
278
+
279
+ it ( 'should throw an exception if it cannot parse the time' , function ( ) {
280
+ var inputDateString = '4/17/2008 11:22:33' ;
281
+
282
+ expect ( function ( ) {
283
+ $ . timepicker . _util . _parseDateTimeInternal ( 'mm/dd/yy' , 'q' , inputDateString , undefined , undefined ) ;
284
+ } ) . toThrow ( 'Wrong time format' ) ;
285
+ } ) ;
286
+ } ) ;
243
287
} ) ;
244
288
245
289
describe ( 'timepicker functions' , function ( ) {
0 commit comments