HTML and CSS Reference
The Chat Client
In this chapter we will use test-driven development to implement a client for the
doing so we will see how to apply the techniques we have learned so far to test DOM
manipulation and event handling.
The DOM is an API just like any other, which means that testing it should be
fairly straightforward so long as we adhere to the single responsibility principle and
keep components loosely coupled. The DOM does potentially present a challenge
in that it consists entirely of host objects, but as we will see, we can work around
the potential problems.
The task at hand is building a simple chat GUI. The resulting application will have
two views: when the user enters the application she will be presented with a form in
which to enter the desired username. Submitting the form will remove it and display
a list of messages and a form to enter new ones in its place. As usual, we will keep
the scope at a minimum to get through the entire exercise, so for example, there
will be no cookie management to remember the user. Throughout the chapter ideas
on how to add more features to the client will be suggested as exercises.