O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required