HTML and CSS Reference
In-Depth Information
if (typeof this.interval == "number") {
interval = this.interval;
}
ajax.request(this.url, {
complete: function () {
setTimeout(function () {
poller.start();
}, interval);
}
});
}
Running the tests once more yields that wonderful green confirmation of
success.
13.1.4 Configurable Headers and Callbacks
Before we can consider the poller somewhat complete we need to allow users of the
object to set request headers and add callbacks. Let's deal with the headers first. The
test in Listing 13.22 inspects the headers passed to the fake XMLHttpRequest
object.
Listing 13.22 Expecting headers to be passed to request
"test should pass headers to request": function () {
this.poller.headers = {
"Header-One": "1",
"Header-Two": "2"
};
this.poller.start();
var actual = this.xhr.headers;
var expected = this.poller.headers;
assertEquals(expected["Header-One"],
actual["Header-One"]);
assertEquals(expected["Header-Two"],
actual["Header-Two"]);
}
This test sets two bogus headers, and simply asserts that they were set on the
transport (and thus can safely be expected to be sent with the request).
You may sometimes be tempted to skip running the tests before writ-
ing the implementation—after all, we know they're going to fail, right? While
 
Search WWH ::




Custom Search