高效的JavaScript代码单元测试方法(7)

发表于:2013-01-11来源:web开发社区作者:Hazem Saleh点击数: 标签:JavaScript
07 input type=password id=password//tdtdspan id=passwordMessage 08 /span/td/tr/table/FORM*/ 09 }; 10 11 ApplicationUtilTest.prototype.testValidateLoginFormBothEmpty = function () { 12 var applicationU
07 <input type="password" id="password"/></td><td><span id="passwordMessage"
08 ></span></td></tr></table></FORM>*/
09 };
10  
11 ApplicationUtilTest.prototype.testValidateLoginFormBothEmpty = function () {
12     var applicationUtil = new appnamespace.ApplicationUtil();
13  
14     /* Simulate empty user name and password */
15     document.getElementById ("username").value = "";
16     document.getElementById ("password").value = "";    
17  
18     applicationUtil.validateLoginForm();
19  
20     assertEquals ("Username is not validated correctly!", "This field is required"
21     document.getElementById("usernameMessage").innerHTML);

原文转自:http://www.ltesting.net