HTML and CSS Reference
In-Depth Information
/* ... */
"test should publish message from current user":
function () {
this.model.currentUser = "cjno";
this.controller.handleSubmit();
assertEquals("cjno", this.model.notify.args[1].user);
}
});
Once again, we extracted common setup code to the setUp method while
adding the test. Passing the test is accomplished by Listing 15.76.
Listing 15.76 Including the current user in the published message
function handleSubmit(event) {
this.model.notify("message", {
user: this.model.currentUser
});
}
The final piece of the puzzle is including the message. The message should be
grabbed from the message form, which means that the test will need to embed some
markup. Listing 15.77 shows the test.
Listing 15.77 Expecting the published message to originate from the form
TestCase("FormControllerHandleSubmitTest", {
setUp: function () {
/*:DOC element = <form>
<fieldset>
<input type="text" name="message" id="message">
<input type="submit" value="Send">
</fieldset>
</form> */
/* ... */
this.controller.setView(this.element);
},
/* ... */
"test should publish message from form": function () {
var el = this.element.getElementsByTagName("input")[0];
Search WWH ::




Custom Search