r1744 - trunk/tests/unit/core
Author: scott.gonzalez
Date: Wed Jan 21 17:45:42 2009
New Revision: 1744
Modified:
trunk/tests/unit/core/selector.js
Log:
Core tests: Tests for :data selector.
Modified: trunk/tests/unit/core/selector.js
==============================================================================
--- trunk/tests/unit/core/selector.js (original)
+++ trunk/tests/unit/core/selector.js Wed Jan 21 17:45:42 2009
@@ -1,5 +1,5 @@
/*
- * core unit tests
+ * selector unit tests
*/
(function($) {
@@ -20,6 +20,63 @@
function isNotTabbable(selector, msg) {
ok($(selector).length && !$(selector).is(':tabbable'), msg);
}
+
+test("data", function() {
+ expect(15);
+
+ var el;
+ function shouldHaveData(msg) {
+ ok(el.is(':data(test)'), msg);
+ }
+ function shouldNotHaveData(msg) {
+ ok(!el.is(':data(test)'), msg);
+ }
+
+ el = $('<div/>');
+ shouldNotHaveData('data never set');
+
+ el = $('<div/>').data('test', null);
+ shouldNotHaveData('data is null');
+
+ el = $('<div/>').data('test', true);
+ shouldHaveData('data set to true');
+
+ el = $('<div/>').data('test', false);
+ shouldNotHaveData('data set to false');
+
+ el = $('<div/>').data('test', 0);
+ shouldNotHaveData('data set to 0');
+
+ el = $('<div/>').data('test', 1);
+ shouldHaveData('data set to 1');
+
+ el = $('<div/>').data('test', '');
+ shouldNotHaveData('data set to empty string');
+
+ el = $('<div/>').data('test', 'foo');
+ shouldHaveData('data set to string');
+
+ el = $('<div/>').data('test', []);
+ shouldHaveData('data set to empty array');
+
+ el = $('<div/>').data('test', [1]);
+ shouldHaveData('data set to array');
+
+ el = $('<div/>').data('test', {});
+ shouldHaveData('data set to empty object');
+
+ el = $('<div/>').data('test', {foo: 'bar'});
+ shouldHaveData('data set to object');
+
+ el = $('<div/>').data('test', new Date());
+ shouldHaveData('data set to date');
+
+ el = $('<div/>').data('test', /test/);
+ shouldHaveData('data set to regexp');
+
+ el = $('<div/>').data('test', function() {});
+ shouldHaveData('data set to function');
+});
test("focusable - visible, enabled elements", function() {
expect(18);