Cleaned up QUnit test structure
This commit is contained in:
parent
0e984762d5
commit
4cd71972be
17
.jshintrc
17
.jshintrc
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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/)
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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", {
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
function integration(name) {
|
||||
module(name, {
|
||||
setup: function() {
|
||||
Ember.run(Discourse, Discourse.advanceReadiness);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
Discourse.reset();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -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() {
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
||||
|
|
|
@ -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, {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
|
||||
|
||||
module("Discourse.Composer");
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue