HTML and CSS Reference
In-Depth Information
tddjs.util is undefined
()@http://localhost:4224/.../observable_test.js:5 Making the Test Pass
Fear not! Failure is actually a good thing: It tells us where to focus our efforts.
The first serious problem is that tddjs.util doesn't exist. Listing 11.5 adds
the object using the tddjs.namespace method. Save the listing in src/
observable.js .
Listing 11.5 Creating the util namespace
Running the tests again yields a new error, as seen in Listing 11.6.
Listing 11.6 Tests still failing
chris@laptop:~/projects/observable $ jstestdriver --tests all
Total 1 tests (Passed: 0; Fails: 0; Errors: 1) (1.00 ms)
Firefox 3.6.3 Linux: Run 1 tests \
(Passed: 0; Fails: 0; Errors 1) (1.00 ms)
Observable.addObserver.test \
should store function error (1.00 ms): \
tddjs.util.Observable is not a constructor
Listing 11.7 fixes this new issue by adding an empty Observable constructor.
Listing 11.7 Adding the constructor
(function () {
function Observable() {
tddjs.util.Observable = Observable;
To work around the issues with named function expressions discussed in
Chapter 5, Functions, the constructor is defined using a function declaration in-
side an immediately called closure. Running the test once again brings us directly
to the next problem, seen in Listing 11.8.
Search WWH ::

Custom Search