<!DOCTYPE html>
<html lang="en">
<head>
<title>QUnit/Sinon.JS</title>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
</head>
<body>
<h1 id="qunit-header">QUnit/Sinon.JS Test</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script type="text/javascript" src="js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<script type="text/javascript" src="js/sinon-1.17.2.js"></script>
<script type="text/javascript" src="js/sinon-qunit-1.0.0.js"></script>
<script>
QUnit.test("sinon test",function(assert){
var obj = {
fn1:function(){
console.log(111);
return 333;
},
method:function(){
return 100;
}
};
function fn(){
alert(1)
}
//var spy = sinon.spy(obj,"method");
var callback = sinon.spy();
callback();
callback();
assert.ok(callback.calledOnce,"ok");
});
</script>
</body>
</html>
转载于:https://my.oschina.net/u/1792175/blog/598090
来源:https://blog.csdn.net/chuomu8273/article/details/100682052