HTML and CSS Reference
In-Depth Information
/* ... */
this.observable.observe("event", observer1);
this.observable.observe("event", observer2);
/* ... */
},
"test should pass through arguments": function () {
/* ... */
this.observable.observe("event", function () {
actual = arguments;
});
/* ... */
},
"test should notify all even when some fail": function () {
/* ... */
this.observable.observe("event", observer1);
this.observable.observe("event", observer2);
/* ... */
},
"test should call observers in the order they were added":
function () {
/* ... */
this.observable.observe("event", observer1);
this.observable.observe("event", observer2);
/* ... */
},
/* ... */
});
Unsurprisingly, this causes all the tests to fail as observe throws an exception,
because the argument it thinks is the observer is not a function. To get tests back to
green we simply add a formal parameter to observe , as seen in Listing 11.43.
Listing 11.43 Adding a formal event parameter to observe
function observe(event, observer) {
/* ... */
}
We will repeat this exercise with both hasObserver and notify as well, to
make room for tests that describe actual functionality. I will leave updating these
 
Search WWH ::




Custom Search