FIX: user-card tests

This commit is contained in:
Régis Hanol 2015-03-04 13:02:36 +01:00
parent f7c9ee703d
commit 809edd4da3
3 changed files with 17 additions and 6 deletions

View File

@ -3,7 +3,8 @@
#user-card { #user-card {
position: absolute; position: absolute;
width: 500px; width: 500px;
left: 20px; left: -9999px;
top: -9999px;
z-index: 990; z-index: 990;
box-shadow: 0 2px 6px rgba(0,0,0,.6); box-shadow: 0 2px 6px rgba(0,0,0,.6);
margin-top: -2px; margin-top: -2px;

View File

@ -1,5 +1,5 @@
/* exported exists, count, present, blank, containsInstance, not */ /* exported exists, count, present, blank, containsInstance, not, visible */
// Test helpers
function exists(selector) { function exists(selector) {
return !!count(selector); return !!count(selector);
} }
@ -23,3 +23,14 @@ function containsInstance(collection, klass, text) {
function not(state, message) { function not(state, message) {
ok(!state, message); ok(!state, message);
} }
function visible(selector) {
return find(selector + ":visible").length > 0;
}
function invisible(selector) {
var $items = find(selector + ":visible");
return $items.length === 0 ||
$items.css("opacity") === "0" ||
$items.css("visibility") === "hidden";
}

View File

@ -3,12 +3,11 @@ integration("User Card");
test("card", function() { test("card", function() {
visit('/'); visit('/');
// will fix ok(invisible('#user-card'), 'user card is invisible by default');
// ok(find('#user-card:visible').length === 0, 'user card is invisible by default');
click('a[data-user-card=eviltrout]:first'); click('a[data-user-card=eviltrout]:first');
andThen(function() { andThen(function() {
ok(find('#user-card:visible').length === 1, 'card should appear'); ok(visible('#user-card'), 'card should appear');
}); });
}); });