Add qunit test structure
This commit is contained in:
parent
2dfa28cea9
commit
2129d1fc67
18
javascripts/tests/runner.html
Normal file
18
javascripts/tests/runner.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Table Tests</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">test markup, will be hidden</div>
|
||||
</body>
|
||||
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
||||
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
|
||||
<script type="text/javascript" src="../tabs.js"></script>
|
||||
<script type="text/javascript" src="tests.js"></script>
|
||||
</html>
|
41
javascripts/tests/tests.js
Normal file
41
javascripts/tests/tests.js
Normal file
@ -0,0 +1,41 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
module("Table markup creation");
|
||||
|
||||
var data = {
|
||||
"table": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "firstName",
|
||||
"displayName": "First Name"
|
||||
},
|
||||
{
|
||||
"name": "lastName",
|
||||
"displayName": "Last Name"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
test("Generate table headers", function () {
|
||||
|
||||
$('#qunit-fixture').tablePlugin(data);
|
||||
|
||||
var table = $('#qunit-fixture');
|
||||
var thead = table.find("thead tr");
|
||||
|
||||
equal(thead.find('th').size(),
|
||||
data.table.columns.length,
|
||||
"Expect number of generated table headers to match number in model");
|
||||
|
||||
equal(thead.find('th').first().html(),
|
||||
data.table.columns[0].displayName,
|
||||
"Expect inner HTML to be display name");
|
||||
|
||||
equal(thead.find('th').first().attr('data-name'),
|
||||
data.table.columns[0].name,
|
||||
"Expect data-name attribute to be set to name");
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user