mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
Refactor: Move Topic Details into better objects, identity map, tests, query string filters
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
// Test helpers
|
||||
var resolvingPromise = Ember.Deferred.promise(function (p) {
|
||||
p.resolve();
|
||||
})
|
||||
});
|
||||
|
||||
var resolvingPromiseWith = function(result) {
|
||||
return Ember.Deferred.promise(function (p) { p.resolve(result); });
|
||||
};
|
||||
|
||||
function exists(selector) {
|
||||
return !!count(selector);
|
||||
@ -11,22 +15,14 @@ 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);
|
||||
ok(!Ember.isEmpty(obj), text);
|
||||
}
|
||||
|
||||
function blank(obj, text) {
|
||||
equal(objBlank(obj), true, text);
|
||||
ok(Ember.isEmpty(obj), text);
|
||||
}
|
||||
|
||||
function containsInstance(collection, klass, text) {
|
||||
ok(klass.detectInstance(_.first(collection)), text);
|
||||
}
|
Reference in New Issue
Block a user