Skip to content

Commit b23be92

Browse files
committed
Test timepicker.timezoneAdjust()
1 parent 7c389ba commit b23be92

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/jquery-ui-timepicker-addon_spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,29 @@ describe('datetimepicker', function() {
266266
});
267267
});
268268

269+
describe('timezoneAdjust', function() {
270+
it('does not change the date if the timezone yields NaN for an offset', function() {
271+
var expectedDate = new Date();
272+
273+
expect($.timepicker.timezoneAdjust(expectedDate, NaN)).toEqual(expectedDate);
274+
});
275+
276+
it('changes the minutes by the time zone offset minutes', function() {
277+
var inputDate,
278+
originalMillis,
279+
expectedDifference,
280+
adjustedDate;
281+
282+
inputDate = new Date();
283+
originalMillis = inputDate.getTime();
284+
expectedDifference = -(inputDate.getTimezoneOffset() + 60) * 60 * 1000;
285+
286+
adjustedDate = $.timepicker.timezoneAdjust(inputDate, '+0100');
287+
288+
expect(adjustedDate.getTime() - originalMillis).toBe(expectedDifference);
289+
});
290+
});
291+
269292
describe('log', function() {
270293
it('calls console.log with the message if the console exists', function() {
271294
var expectedMessage = "Just what I expected!";

0 commit comments

Comments
 (0)