discourse/test/javascripts/helpers/assertions.js

43 lines
984 B
JavaScript
Raw Normal View History

/* exported exists, count, present, blank, containsInstance, not, visible, invisible */
2015-03-04 20:02:36 +08:00
2013-06-21 01:58:54 +08:00
function exists(selector) {
return !!count(selector);
}
function count(selector) {
return find(selector).length;
}
function present(obj, text) {
ok(!Ember.isEmpty(obj), text);
2013-06-21 01:58:54 +08:00
}
function blank(obj, text) {
ok(Ember.isEmpty(obj), text);
}
function containsInstance(collection, klass, text) {
ok(klass.detectInstance(_.first(collection)), text);
}
function not(state, message) {
ok(!state, message);
}
2015-03-04 20:02:36 +08:00
function visible(selector) {
return find(selector + ":visible").length > 0;
}
Ember.Test.registerAsyncHelper('selectDropdown', function(app, selector, itemId) {
var $select2 = find(selector);
$select2.select2('val', itemId.toString());
$select2.trigger("change");
});
2015-03-04 20:02:36 +08:00
function invisible(selector) {
var $items = find(selector + ":visible");
return $items.length === 0 ||
$items.css("opacity") === "0" ||
$items.css("visibility") === "hidden";
}