Skip to content
Permalink
Browse files

Core tests: Tests for :data selector.

  • Loading branch information
scottgonzalez committed Jan 22, 2009
1 parent e1b16e2 commit 621392624ba73697135fd43e0741f5983ea1d87a
Showing with 58 additions and 1 deletion.
  1. +58 −1 tests/unit/core/selector.js
@@ -1,5 +1,5 @@
/*
* core unit tests
* selector unit tests
*/
(function($) {

@@ -21,6 +21,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);

0 comments on commit 6213926

Please sign in to comment.
You can’t perform that action at this time.