HTML and CSS Reference
In-Depth Information
Listing 15.37 Feature tests for userFormController
(function () {
if (typeof tddjs == "undefined" ||
typeof document == "undefined") {
return;
}
var dom = tddjs.dom;
var util = tddjs.util;
var chat = tddjs.namespace("chat");
if (!dom
||
!dom.addEventHandler
||
!util
||
||
||
!util.observable
!Object.create
!document.getElementsByTagName
||
!Function.prototype.bind) {
return;
}
/* ... */
}());
Note that because the tests aren't storing a reference to addEventHandler
before stubbing and restoring it in tearDown as we did before, we are effectively
overwriting it for the entire test suite. In this particular case this isn't a problem,
because none of the tests will register actual DOM event handlers.
When you have added the above feature tests, you need to have the event utilities
from Chapter 10, Feature Detection, in tdd.js for the tests to pass, because the
controller will not be defined if its dependencies are not available.
15.3 Using the Client with the Node.js Backend
Having successfully completed one of three client components, we will add some
plumbing to the “chapp” Node application from Chapter 14, Server-Side JavaScript
with Node.js, to have it serve the client. As a low-level runtime, Node does not
have a concept of serving static files through its http server module. Doing so
requires matching the request's URL to a file on disk and streaming it to the client.
Implementing this is well outside the scope of this chapter, so instead we will use
a module by Felix Geisend orfer called node-paperboy. 2
A version guaranteed to
2. http://github.com/felixge/node-paperboy
 
 
Search WWH ::




Custom Search