diff options
author | Jan Lehnardt <jan@apache.org> | 2010-06-02 17:45:56 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2010-06-02 17:45:56 +0000 |
commit | baf25cefa01d305a47087686becef7de7147321a (patch) | |
tree | 4325283b8e57064be26daf421d8ded8930b36c9c /share/www/script/jspec/jspec.jquery.js | |
parent | 7fe84eba9982ebb3bcaa48b7aa28fdd2e130422d (diff) |
Add tests for couch.js and jquery.couch.js
Patch by Lena Herrmann.
Closes COUCHDB-783.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@950689 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/jspec/jspec.jquery.js')
-rw-r--r-- | share/www/script/jspec/jspec.jquery.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/share/www/script/jspec/jspec.jquery.js b/share/www/script/jspec/jspec.jquery.js new file mode 100644 index 00000000..fcad7ab9 --- /dev/null +++ b/share/www/script/jspec/jspec.jquery.js @@ -0,0 +1,72 @@ + +// JSpec - jQuery - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed) + +JSpec +.requires('jQuery', 'when using jspec.jquery.js') +.include({ + name: 'jQuery', + + // --- Initialize + + init : function() { + jQuery.ajaxSetup({ async: false }) + }, + + // --- Utilities + + utilities : { + element: jQuery, + elements: jQuery, + sandbox : function() { + return jQuery('<div class="sandbox"></div>') + } + }, + + // --- Matchers + + matchers : { + have_tag : "jQuery(expected, actual).length === 1", + have_one : "alias have_tag", + have_tags : "jQuery(expected, actual).length > 1", + have_many : "alias have_tags", + have_any : "alias have_tags", + have_child : "jQuery(actual).children(expected).length === 1", + have_children : "jQuery(actual).children(expected).length > 1", + have_text : "jQuery(actual).text() === expected", + have_value : "jQuery(actual).val() === expected", + be_enabled : "!jQuery(actual).attr('disabled')", + have_class : "jQuery(actual).hasClass(expected)", + + be_visible : function(actual) { + return jQuery(actual).css('display') != 'none' && + jQuery(actual).css('visibility') != 'hidden' && + jQuery(actual).attr('type') != 'hidden' + }, + + be_hidden : function(actual) { + return !JSpec.does(actual, 'be_visible') + }, + + have_classes : function(actual) { + return !JSpec.any(JSpec.toArray(arguments, 1), function(arg){ + return !JSpec.does(actual, 'have_class', arg) + }) + }, + + have_attr : function(actual, attr, value) { + return value ? jQuery(actual).attr(attr) == value: + jQuery(actual).attr(attr) + }, + + 'be disabled selected checked' : function(attr) { + return 'jQuery(actual).attr("' + attr + '")' + }, + + 'have type id title alt href src sel rev name target' : function(attr) { + return function(actual, value) { + return JSpec.does(actual, 'have_attr', attr, value) + } + } + } +}) + |