[英]Writing jasmine test for looping javascript function
该功能将是
function checkCond(a, b){
if(a===true){
if(b===true){
document.getElementById("theId").innerHtml = "success";
}
else if(b===false){
document.getElementById("theId").innerHtml = "Fails";
}
else{
document.getElementById("theId").innerHtml = "Required";
}
}
else{
if(b===true){
document.getElementById("theId").innerHtml = "success";
}
}
}
我们如何为上述循环功能编写茉莉花测试?
我看不到此函数有任何循环,但是对其进行测试应该足够简单。 例如,
beforeEach(function() {
// setup your dom element. this depends on your environment and
// jasmine version. see docs.
});
it('should succeed when both conditions are true', function() {
checkCond( true, true );
expect(document.getElementById("theId").innerHtml).toBe "success"
});
等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.