HTML and CSS Reference
In-Depth Information
Are there other cases related to the request token that should be tested? Think it
over, write tests, and update the implementation to fit.
13.4.7 Publishing Data
The Comet client also needs a notify method. As an exercise, try to use TDD to
implement this method according to these requirements:
The signature should be client.notify(topic, data)
The method should POST to client.url
The data should be sent as an object with properties topic and data
What Content-Type will you send the request with? Will the choice of
Content-Type affect the body of the request?
13.4.8 Feature Tests
The cometClient object only depends directly on observable and the poller,
so adding feature tests to allow it to fail gracefully is fairly simple, as seen in
Listing 13.70.
Listing 13.70 Comet client feature tests
(function () {
if (typeof tddjs == "undefined") {
var ajax = tddjs.namespace("ajax");
var util = tddjs.namespace("util");
if (!ajax.poll
!util.observable) {
/* ... */
Search WWH ::

Custom Search