diff options
author | Scott González <scott.gonzalez@gmail.com> | 2009-01-22 01:45:42 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2009-01-22 01:45:42 +0000 |
commit | 621392624ba73697135fd43e0741f5983ea1d87a (patch) | |
tree | 4193432ea88cb4d842ef3d64f4f796c0650aab21 /tests | |
parent | e1b16e22ddb4a40ff4c8d81ca828f8bc6a9f9ced (diff) | |
download | jquery-ui-621392624ba73697135fd43e0741f5983ea1d87a.tar.gz jquery-ui-621392624ba73697135fd43e0741f5983ea1d87a.zip |
Core tests: Tests for :data selector.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/core/selector.js | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index 73df0c3fc..0e647d453 100644 --- a/tests/unit/core/selector.js +++ b/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); |