HTML and CSS Reference
In-Depth Information
will serve as a test-driven introduction to the topic. JavaScript's dynamic nature
enables us to stub manually without too much hassle. However, when we are done
with this chapter we will get a better overview of patterns that would be helpful to
have automated, even in the dynamic world of JavaScript. Chapter 16, Mocking and
Stubbing, will provide a more complete background on both stubs and mocks, but
you should be able to follow the examples in this and following chapters without
any prior experience with them.
12.2 Implementing the Request Interface
As in Chapter 11, The Observer Pattern, we will use JsTestDriver to run tests for
this project. Please refer to Chapter 3, Tools of the Trade, for an introduction and
installation guide.
12.2.1 Project Layout
The project layout can be seen in Listing 12.1 and the contents of the JsTestDriver
configuration file are found in Listing 12.2.
Listing 12.1 Directory layout for the ajax project
chris@laptop:~/projects/ajax $ tree
.
| -- jsTestDriver.conf
| -- lib
| '-- tdd.js
| -- src
| '-- ajax.js
| '-- request.js
`-- test
'-- ajax_test.js
'-- request_test.js
Listing 12.2 The jsTestDriver.conf file
server: http://localhost:4224
load:
- lib/*.js
- src/*.js
- test/*.js
 
 
Search WWH ::




Custom Search