diff options
Diffstat (limited to 'test/test.js')
-rw-r--r-- | test/test.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/test/test.js b/test/test.js index 88d59e7..44ab452 100644 --- a/test/test.js +++ b/test/test.js @@ -1,12 +1,26 @@ -test("Properly executed", function() { - // Create one once() call. - $('#test1 span').once().data('test1', 'foobar'); +test("ID required", function() { + expect(1); + try { + $("#test1 span").once(); + } + catch (e) { + ok(e, "Error is triggered when ID is missing."); + } +}); + +test(".once('test1-2') properly executed", function() { + // Create one once('test1-2') call. + $('#test1 span').once('test1-2').data('test1-2', 'foo'); + + // Create another once('test1-2') call. + $('#test1 span').once('test1-2').data('test1-2', 'bar'); - var data = $('#test1 span').data('test1'); - ok(data === "foobar"); + // The data should result to the first once() call. + var data = $('#test1 span').data('test1-2'); + ok(data === "foo"); }); -test("Called only once", function() { +test("Called only once, counted", function() { // Count the number of times once() was called. $('#test2 span').data('count', 0); |