前端单元测试插件qunit.js使用示例
2016-08-09 09:00
513 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/>
<link rel="stylesheet" href="css/qunit-1.11.0.css">
<script src="http://v3.faqrobot.org/hvb/com/js/jquery-1.11.3.min.js"></script>
<script src="js/qunit-1.11.0.js"></script>
<title>test</title>
<style>
* {
margin: 0;
padding: 0;
}
body, html {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<h1 id="qunit-header">QUnit测试</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">测试标记</div>
<input id="autocomplete" class="">
<script>
/*$.ajax({
url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
dataType: 'jsonp',
success: function(data) {
var html = '';
for(var i=0,len=data.topAsk.length; i<len; i++) {
console.log(data.topAsk[i]);
html += '<p>{question}</p>';
}
format($('.a').innerHtml, html)
},
});
var x = format('my name is {name}', {
name: 'hwb',
});
console.log(x);*/
/*test("async测试", function() {
stop();
stop();
$.ajax({
url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
dataType: 'jsonp',
success: function(data) {
equal(data.topAsk.length, 5);
start();
},
});
$.ajax({
url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
dataType: 'jsonp',
success: function(data) {
equal(data.topAsk.length, 5);
start();
},
});
});*/
/*function A(name, age) {
this.name = name;
this.age = age;
}
A.prototype.addName = function() {
this.name += this.name;
return this.name;
}
A.prototype.addAge = function() {
this.age += 1;
}
module('A类测试', {
setup: function() {
this.a1 = new A('hwb', 23);
},
});
test("module的使用", function() {
this.a1.addAge();
equal(this.a1.age, 24);
this.a1.addName();
equal(this.a1.name, 'hwbhwb');
});*/
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/>
<link rel="stylesheet" href="css/qunit-1.11.0.css">
<script src="http://v3.faqrobot.org/hvb/com/js/jquery-1.11.3.min.js"></script>
<script src="js/qunit-1.11.0.js"></script>
<title>test</title>
<style>
* {
margin: 0;
padding: 0;
}
body, html {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<h1 id="qunit-header">QUnit测试</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">测试标记</div>
<input id="autocomplete" class="">
<script>
/*$.ajax({
url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
dataType: 'jsonp',
success: function(data) {
var html = '';
for(var i=0,len=data.topAsk.length; i<len; i++) {
console.log(data.topAsk[i]);
html += '<p>{question}</p>';
}
format($('.a').innerHtml, html)
},
});
var x = format('my name is {name}', {
name: 'hwb',
});
console.log(x);*/
/*test("async测试", function() {
stop();
stop();
$.ajax({
url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
dataType: 'jsonp',
success: function(data) {
equal(data.topAsk.length, 5);
start();
},
});
$.ajax({
url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
dataType: 'jsonp',
success: function(data) {
equal(data.topAsk.length, 5);
start();
},
});
});*/
/*function A(name, age) {
this.name = name;
this.age = age;
}
A.prototype.addName = function() {
this.name += this.name;
return this.name;
}
A.prototype.addAge = function() {
this.age += 1;
}
module('A类测试', {
setup: function() {
this.a1 = new A('hwb', 23);
},
});
test("module的使用", function() {
this.a1.addAge();
equal(this.a1.age, 24);
this.a1.addName();
equal(this.a1.name, 'hwbhwb');
});*/
</script>
</body>
</html>
相关文章推荐
- 前端拖拽插件gridster.js介绍与使用示例
- 前端拖拽插件gridster.js介绍与使用示例
- 前端拖拽插件gridster.js介绍与使用示例
- 使用QUnit对JS进行单元测试
- 提示框插件jBox.js的使用示例
- my97前端日期插件使用示例
- 颜色动画插件jquery.color.js的使用示例
- 实用前端JS工具类(验证,AJAX请求封装,分页插件等)真实项目使用
- 前端插件datatable.js的使用
- 使用js插件在前端页面上画图
- 自动补全插件autocomplete.js的使用示例
- 分页插件jPages.js的使用示例
- 二维码插件jquery.qrcode.js的使用示例
- jQuery插件artDialog.js使用与关闭方法示例
- 使用 Qunit 对js代码进行单元测试
- jquery.fileupload.js插件使用--前两篇日志中两个类的使用示例
- 手机端滑动、长按事件插件touchswipe.js的使用示例
- 省市区选择插件jquery.cityselect.js的使用示例
- jQuery使用ajaxSubmit()提交表单示例==引入jquery.form.js插件(专门提交表单)