HTML and CSS Reference
In many ways this project is a continuation of the previous one. Most files can be
recognized from the previous chapter. The request.js file, and its test case are
brought along for further development, and we will add some functionality to them.
Note that the final refactoring discussed in Chapter 12, Abstracting Browser Differ-
ences: Ajax, in which tdd.ajax.request returns an object representing the re-
quest, is not implemented. Doing so would probably be a good idea, but we'll try not
to tie the two interfaces too tightly together, allowing the refactoring to be performed
at some later time. Sticking with the code exactly as we developed it in the previous
chapter will avoid any surprises, allowing us to focus entirely on new features.
The jsTestDriver.conf configuration file needs a slight tweak for this
project. The lib directory now contains an ajax.js file that depends on the
tddjs object defined in tdd.js ; however, it will be loaded before the file it
depends on. The solution is to manually specify the tdd.js file first, then load the
remaining lib files, as seen in Listing 13.2.
Listing 13.2 Ensuring correct load order of test files
13.1.2 The Poller: tddjs.ajax.poller
In Chapter 12, Abstracting Browser Differences: Ajax, we built the request interface
by focusing heavily on the simplest use case, calling tddjs.ajax.get or
tddjs.ajax.post to make one-off GET or POST requests. In this chapter we
are going to flip things around and focus our efforts on building a stateful object,
such as the one we realized could be refactored from tddjs.ajax.request .
This will show us a different way to work, and, because test-driven development
really is about design and specification, a slightly different result. Once the object
is useful we will implement a cute one-liner interface on top of it to go along with
the get and post methods.