diff options
author | Stephen Vance <steve@vance.com> | 2013-07-06 17:23:42 -0400 |
---|---|---|
committer | Stephen Vance <steve@vance.com> | 2013-07-06 22:19:55 -0400 |
commit | 3c4e42e60e0a9e994f50586c079bf0b1ded369a0 (patch) | |
tree | 2b4fa081e15b2805c844daa6ebe416b95782d909 /test | |
parent | ea4252ea21bb010eec88d9377d71ade2aa85d90e (diff) | |
download | jQuery-Timepicker-Addon-3c4e42e60e0a9e994f50586c079bf0b1ded369a0.zip jQuery-Timepicker-Addon-3c4e42e60e0a9e994f50586c079bf0b1ded369a0.tar.gz jQuery-Timepicker-Addon-3c4e42e60e0a9e994f50586c079bf0b1ded369a0.tar.bz2 |
Test and simplify convert24to12, including making it resistant to out of bounds values.
Diffstat (limited to 'test')
-rw-r--r-- | test/jquery-ui-timepicker-addon_spec.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/jquery-ui-timepicker-addon_spec.js b/test/jquery-ui-timepicker-addon_spec.js index 94ee485..29f8648 100644 --- a/test/jquery-ui-timepicker-addon_spec.js +++ b/test/jquery-ui-timepicker-addon_spec.js @@ -65,5 +65,29 @@ describe('datetimepicker', function() { expect(util._isEmptyObject(testObject)).toBe(true); }) }); + + describe('convert24to12', function() { + it('should return the value for a non-zero value less than 12', function() { + var expectedHour = 6; + + expect(util._convert24to12(expectedHour)).toBe("" + expectedHour); + }); + + it('should return 12 hours less if the value is greater than 12 and less than 24', function() { + var expectedHour = 7; + + expect(util._convert24to12(expectedHour + 12)).toBe("" + expectedHour); + }); + + it('should return 12 if the normalized value is 0', function() { + expect(util._convert24to12(0)).toBe('12'); + }); + + it('should normalize values that are clearly out of the expected range', function() { + var expectedValue = 11; + + expect(util._convert24to12(expectedValue + 12 * 3)).toBe("" + expectedValue); + }) + }); }); });
\ No newline at end of file |