Cleaned up QUnit test structure

This commit is contained in:
Robin Ward 2013-06-20 13:58:54 -04:00
parent 0e984762d5
commit 4cd71972be
24 changed files with 83 additions and 87 deletions

View File

@ -31,7 +31,22 @@
"PreloadStore",
"Handlebars",
"I18n",
"bootbox"],
"bootbox",
"module",
"integration",
"test",
"ok",
"expect",
"equal",
"blank",
"present",
"visit",
"count",
"exists",
"asyncTest",
"find",
"resolvingPromise",
"sinon"],
"browser":true,
"rhino":false,
"devel":true,

View File

@ -77,6 +77,21 @@ predef:
- bootbox
- moment
- _
- module
- integration
- test
- ok
- expect
- equal
- blank
- present
- visit
- count
- exists
- asyncTest
- find
- resolvingPromise
- sinon
browser: true # true if the standard browser globals should be predefined
rhino: false # true if the Rhino environment globals should be predefined

View File

@ -8,8 +8,9 @@ class DiscourseIIFE < Sprockets::Processor
# Only discourse or admin paths
return data unless (path =~ /\/javascripts\/discourse/ || path =~ /\/javascripts\/admin/ || path =~ /\/test\/javascripts/)
# Ignore the js helper
# Ignore the js helpers
return data if (path =~ /test\_helper\.js/)
return data if (path =~ /javascripts\/helpers\//)
# Ignore translations
return data if (path =~ /\/translations/)

View File

@ -1,4 +1,4 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true present:true md5:true */
/*global md5:true */
module("Discourse.BBCode");

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true equal:true exists:true count:true equal:true present:true sinon:true blank:true */
module("Discourse.ClickTrack", {
setup: function() {

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true equal:true exists:true count:true equal:true present:true md5:true */
module("Discourse.Formatter");
var format = "tiny";

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true equal:true exists:true count:true equal:true present:true md5:true */
var store = Discourse.KeyValueStore;
module("Discourse.KeyValueStore", {

View File

@ -1,4 +1,4 @@
/*global module:true test:true ok:true visit:true equal:true exists:true count:true equal:true present:true md5:true sanitizeHtml:true */
/*global sanitizeHtml:true */
module("Discourse.Markdown");

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true equal:true exists:true count:true equal:true present:true md5:true resolvingPromise:true */
module("Discourse.Onebox", {
setup: function() {
this.anchor = $("<a href='http://bla.com'></a>")[0];

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true equal:true count:true present:true asyncTest:true blank:true */
module("Discourse.PreloadStore", {
setup: function() {
PreloadStore.store('bane', 'evil');

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
module("Discourse.Utilities");
var utils = Discourse.Utilities;

View File

@ -0,0 +1,32 @@
// Test helpers
var resolvingPromise = Ember.Deferred.promise(function (p) {
p.resolve();
})
function exists(selector) {
return !!count(selector);
}
function count(selector) {
return find(selector).length;
}
function objBlank(obj) {
if (obj === undefined) return true;
switch (typeof obj) {
case "string":
return obj.trim().length === 0;
case "object":
return $.isEmptyObject(obj);
}
return false;
}
function present(obj, text) {
equal(objBlank(obj), false, text);
}
function blank(obj, text) {
equal(objBlank(obj), true, text);
}

View File

@ -0,0 +1,11 @@
function integration(name) {
module(name, {
setup: function() {
Ember.run(Discourse, Discourse.advanceReadiness);
},
teardown: function() {
Discourse.reset();
}
});
}

View File

@ -1,14 +1,4 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true */
module("Header", {
setup: function() {
Ember.run(Discourse, Discourse.advanceReadiness);
},
teardown: function() {
Discourse.reset();
}
});
integration("Header");
test("/", function() {

View File

@ -1,14 +1,4 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true */
module("List Topics", {
setup: function() {
Ember.run(Discourse, Discourse.advanceReadiness);
},
teardown: function() {
Discourse.reset();
}
});
integration("List Topics");
test("/", function() {

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true */
module("Discourse.Presence");
var testObj = Em.Object.createWithMixins(Discourse.Presence, {

View File

@ -1,4 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
module("Discourse.SelectedPostsCount");
var buildTestObj = function(params, topicParams) {

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
module("Discourse.Category");
test('slugFor', function(){

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
module("Discourse.Composer");

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
module("Discourse.NavItem", {
setup: function() {
this.site = Discourse.Site.instance();

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true blank:true */
module("Discourse.Report");
function reportWithData(data) {

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true present:true equal:true */
module("Discourse.Site");
test('instance', function(){

View File

@ -1,5 +1,3 @@
/*global module:true test:true ok:true visit:true expect:true exists:true count:true present:true equal:true */
module("Discourse.UserAction");
test("collapsing likes", function () {

View File

@ -36,11 +36,12 @@
//= require sinon-1.7.1.js
//= require sinon-qunit-1.0.0.js
//= require helpers/qunit_helpers
//= require helpers/assertions
//= require_tree ./fixtures
//= require_tree .
//= require_self
//= require_tree ./fixtures
// sinon settings
sinon.config = {
injectIntoThis: true,
@ -65,35 +66,3 @@ Discourse.Router.map(function() {
return Discourse.routeBuilder.call(this);
});
// Test helpers
var resolvingPromise = Ember.Deferred.promise(function (p) {
p.resolve();
})
function exists(selector) {
return !!count(selector);
}
function count(selector) {
return find(selector).length;
}
function objBlank(obj) {
if (obj === undefined) return true;
switch (typeof obj) {
case "string":
return obj.trim().length === 0;
case "object":
return $.isEmptyObject(obj);
}
return false;
}
function present(obj, text) {
equal(objBlank(obj), false, text);
}
function blank(obj, text) {
equal(objBlank(obj), true, text);
}