DOMination

The function selectLocalTimezone(), only six lines long and shown in Listing 15-2, forced me to bring in some additional techniques. This function sets the selected value of a selection list representing time zone choices to that of the current or specified time zone. This small piece of code uses jQuery to operate on the DOM.

Listing 15-2: A small method using jQuery to operate on the DOM. The timezone_select property is supposed to be a jQuery collection referencing a <select> tag.

var selectLocalTimezone = function(tp_inst, date) {  if (tp_inst && tp_inst.timezone_select) {    var now = date || new Date();    tp_inst.timezone_select.val(-now.getTimezoneOffset());  }};

I had originally set up the Jasmine ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.