HTML and CSS Reference
In-Depth Information
13.4.2 Introducing ajax.cometClient
As usual we'll start out real simple, asserting that the object in question exists.
ajax.cometClient seems like a reasonable name, and Listing 13.43 tests for its
existence. The test lives in the new file
test/comet _ client _ test.js .
Listing 13.43 Expecting ajax.cometClient to exist
(function () {
var ajax = tddjs.ajax;
TestCase("CometClientTest", {
"test should be object": function () {
assertObject(ajax.cometClient);
}
});
}());
Implementation is a matter of initial file setup as per usual, seen in Listing 13.44.
Listing 13.44 Setting up the comet _ client.js file
(function () {
var ajax = tddjs.namespace("ajax");
ajax.cometClient = {};
}());
13.4.3 Dispatching Data
When an observer is added, we expect it to be called when data is dispatched from
the client. Although we could write tests to dictate the internals of the observe
method, those would be needlessly implementation specific, without describing the
expected behavior very well. Besides, we are going to use the observable object
to handle observers and we don't want to replicate the entire observable test
case for the client's observe method.
We will start by implementing dispatch , which later can help us verify the
behavior of observe . Dispatching is the act of breaking up data received from the
server and sending it out to observers.
 
Search WWH ::




Custom Search