Skip to content

Commit ea7babe

Browse files
committed
Write direct tests for the new computeEffectiveSetting() function. Leave the corresponding variants of splitDateTime() because it still exercises other important facets of the algorithm.
1 parent 11a2545 commit ea7babe

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,6 +2127,7 @@
21272127
_convert24to12: convert24to12,
21282128
_detectSupport: detectSupport,
21292129
_selectLocalTimezone: selectLocalTimezone,
2130+
_computeEffectiveSetting: computeEffectiveSetting,
21302131
_splitDateTime: splitDateTime,
21312132
_parseDateTimeInternal: parseDateTimeInternal
21322133
};

test/jquery-ui-timepicker-addon_spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,32 @@ describe('datetimepicker', function() {
196196
});
197197
});
198198

199+
describe('computeEffectiveSetting', function() {
200+
it('pulls the setting from the passed settings object if it is there', function() {
201+
var expectedUniqueValue = 'This is very unique',
202+
settings = {
203+
property: expectedUniqueValue
204+
};
205+
206+
expect($.timepicker._util._computeEffectiveSetting(settings, 'property')).toBe(expectedUniqueValue);
207+
});
208+
209+
it('pulls the setting from the timepicker defaults if there are no passed settings', function() {
210+
var expectedValue = $.timepicker._defaults.separator;
211+
expect(expectedValue).toBeDefined();
212+
213+
expect($.timepicker._util._computeEffectiveSetting(undefined, 'separator')).toBe(expectedValue);
214+
});
215+
216+
it('pulls the setting from the timepicker defaults if not present in the passed settings', function() {
217+
var expectedValue = $.timepicker._defaults.separator,
218+
settings = {};
219+
expect(expectedValue).toBeDefined();
220+
221+
expect($.timepicker._util._computeEffectiveSetting(settings, 'separator')).toBe(expectedValue);
222+
});
223+
});
224+
199225
describe('splitDateTime', function() {
200226
var expectedDateString = '3/6/1967',
201227
expectedTimeString = '07:32';

0 commit comments

Comments
 (0)