added qUnit unit testing framework, started categories unit tests. finally out of MVP so time to unslackmode :)

v1.18.x
psychobunny 12 years ago
parent faf70d85d8
commit 69f1037d45

@ -5,6 +5,7 @@
<ul class="nav nav-pills">
<li class='active'><a href='/admin/categories/active'>Active</a></li>
<li class=''><a href='/admin/categories/disabled'>Disabled</a></li>
<li class=''><a href='/admin/testing/categories'>Unit Tests</a></li>
</ul>
<!-- TODO: remove inline event listeners. -->

@ -8,6 +8,8 @@
<link rel="stylesheet" href="/vendor/fontawesome/css/font-awesome.min.css">
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript" src="/vendor/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/qunit/qunit-git.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/qunit/qunit-git.css">
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/src/app.js"></script>
<script type="text/javascript" src="/src/templates.js"></script>
@ -74,11 +76,23 @@
<li class=''><a href="/admin/motd"><i class="icon-comment"></i> MOTD</a></li>
<li class="nav-header">Social Authentication</li>
<li class=''><a href='/admin/twitter'><i class='icon-twitter'></i>Twitter</a></li>
<li class=''><a href='/admin/facebook'><i class='icon-facebook'></i>Facebook</a></li>
<li class=''><a href='/admin/gplus'><i class='icon-google-plus'></i>Google+</a></li>
<li class="nav-header">Custom Modules</li>
<li class=''><a href='/admin/twitter'><i class='icon-twitter-sign'></i> Twitter</a></li>
<li class=''><a href='/admin/facebook'><i class='icon-facebook-sign'></i> Facebook</a></li>
<li class=''><a href='/admin/gplus'><i class='icon-google-plus-sign'></i> Google+</a></li>
<!--<li class="nav-header">Custom Modules</li>-->
<!-- <li class=''><a href=''>Search</a></li> -->
<li class="nav-header">Unit Tests</li>
<ul class="nav nav-list">
<li class=''><a href='/admin/testing/categories'>Categories</a></li>
<li class=''><a href='/admin/testing/topics'>Topics</a></li>
<li class=''><a href='/admin/testing/posts'>Posts</a></li>
<li class=''><a href='/admin/testing/accounts'>Accounts</a></li>
<li class=''><a href='/admin/testing/chat'>Chat</a></li>
<li class=''><a href='/admin/testing/notifications'>Notifications</a></li>
<li class=''><a href='/admin/testing/friends'>Friends</a></li>
<li class=''><a href='/admin/testing/feed'>RSS Feed</a></li>
<li class=''><a href='/admin/testing/emails'>Emails</a></li>
</ul>
</ul>
</div><!--/.well -->
</div><!--/span-->

@ -0,0 +1,33 @@
<h1>Categories Unit Tests</h1>
<hr />
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script type="text/javascript">
jQuery(document).ready(function () {
QUnit.init();
asyncTest( "Loading Categories", function() {
jQuery.get(config.api_url + 'home', function(data) {
ok( data.categories.length > 0, JSON.stringify(data.categories) );
start();
for (var i = 0, ii = data.categories.length; i < ii; i++) {
var category = data.categories[i],
slug = 'category/' + category.slug;
asyncTest( "Loading Category '" + category.name + "' located at " + slug, function() {
jQuery.get(config.api_url + slug, function(data) {
ok( data.category_name, JSON.stringify(data) ); //todo: check this against data.categories
start();
});
});
}
});
});
QUnit.start();
});
</script>

@ -1,5 +1,6 @@
{
"custom_mapping": {
"admin/testing/categories[^]*": "admin/testing/categories",
"admin/topics[^]*": "admin/topics",
"admin/categories[^]*": "admin/categories",
"admin/users[^]*": "admin/users",

@ -24,6 +24,17 @@ var user = require('./../user.js'),
});
}(routes[i]));
}
var unit_tests = ['categories'];
for (var i=0, ii=unit_tests.length; i<ii; i++) {
(function(route) {
app.get('/admin/testing/' + route, Admin.isAdmin, function(req, res) {
res.send(templates['admin/header'] + app.create_route('admin/testing/' + route) + templates['admin/footer']);
});
}(unit_tests[i]));
}
}());
//todo consolidate.

Loading…
Cancel
Save