HTML and CSS Reference
In-Depth Information
Listing 15.28 Expecting handleSubmit to notify observers
"test should notify observers of username": function () {
var input = this.element.getElementsByTagName("input")[0];
input.value = "Bullrog";
var observer = stubFn();
this.controller.observe("user", observer);
assertEquals("Bullrog", observer.args[0]);
That test should trigger all kinds of duplication alarms. Don't worry, we'll
get on fixing it shortly. As expected, the test fails because the controller has no
observe method. To fix this, we can extend the controller with tddjs.util.
observable . For this to work we need to fetch the observable implementation
from Chapter 11, The Observer Pattern, in lib/observable.js . Furthermore,
because lib/tdd.js always needs to load before any of the other modules, we
must also update jsTestDriver.conf , as Listing 15.29 shows.
Listing 15.29 Updated jsTestDriver.conf
server: http://localhost:4224
- lib/tdd.js
- lib/*.js
- src/*.js
- test/*.js
Plumbing aside, we can now update the controller implementation, as seen in
Listing 15.30.
Listing 15.30 Making userFormController observable
(function () {
var dom = tddjs.namespace("dom");
var util = tddjs.util;
var chat = tddjs.namespace("chat");
/* ... */
Search WWH ::

Custom Search