diff options
author | Stephen Vance <steve@vance.com> | 2013-07-13 23:43:47 -0400 |
---|---|---|
committer | Stephen Vance <steve@vance.com> | 2013-07-13 23:43:47 -0400 |
commit | f589d84fe533c487dd51fcc4afb1f0de69c7f2b1 (patch) | |
tree | f01f2548d5a23926dbbec8cf879e05e68baea176 | |
parent | ff993634d7d371e03e887fc8694b8a0a175b5983 (diff) | |
download | jQuery-Timepicker-Addon-f589d84fe533c487dd51fcc4afb1f0de69c7f2b1.zip jQuery-Timepicker-Addon-f589d84fe533c487dd51fcc4afb1f0de69c7f2b1.tar.gz jQuery-Timepicker-Addon-f589d84fe533c487dd51fcc4afb1f0de69c7f2b1.tar.bz2 |
Tests for splitDateTime, except for error paths.
-rw-r--r-- | test/jquery-ui-timepicker-addon_spec.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/jquery-ui-timepicker-addon_spec.js b/test/jquery-ui-timepicker-addon_spec.js index 8a96aaf..d2b591a 100644 --- a/test/jquery-ui-timepicker-addon_spec.js +++ b/test/jquery-ui-timepicker-addon_spec.js @@ -195,6 +195,51 @@ describe('datetimepicker', function() { expect(timepicker.timezone_select.val()).toBe(timezoneOffset); }); }); + + describe('splitDateTime', function() { + var expectedDateString = '3/6/1967', + expectedTimeString = '07:32'; + + it('splits a date and time into its parts using the default separator', function() { + var inputDateTimeString = expectedDateString + $.timepicker._defaults.separator + expectedTimeString, + result; + + result = $.timepicker._util._splitDateTime('', inputDateTimeString, {}, {}); + + expect(result).toEqual([expectedDateString, expectedTimeString]); + }); + + it('splits a date and time into its parts using a supplied separator', function() { + var separator = '-', + inputDateTimeString = expectedDateString + separator + expectedTimeString, + result; + + result = $.timepicker._util._splitDateTime('', inputDateTimeString, {}, {separator: separator}); + + expect(result).toEqual([expectedDateString, expectedTimeString]); + }); + + it('splits a date and time into its parts when there are multiple separators in the time format', function() { + var timeFormat = 'hh mm tt', + separator = ' ', + alternateTimeString = '07 32 am', + inputDateTimeString = expectedDateString + separator + alternateTimeString, + timeSettings = {separator: separator, timeFormat: timeFormat}, + result; + + result = $.timepicker._util._splitDateTime('', inputDateTimeString, {}, timeSettings); + + expect(result).toEqual([expectedDateString, alternateTimeString]); + }); + + it('splits only a date into itself', function() { + var result = $.timepicker._util._splitDateTime('', expectedDateString, {}, {}); + + expect(result).toEqual([expectedDateString, '']); + }); + + // TODO: Should test the error path, but not sure what throws the error or what the message looks like. + }); }); describe('timepicker functions', function() { |