summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRob Loach <robloach@gmail.com>2014-11-03 00:42:50 -0800
committerRob Loach <robloach@gmail.com>2014-11-03 00:42:50 -0800
commit43af89bfb0d71acf447ab3c21b552facb461da6a (patch)
tree638a10e1ecaeb9d143a861255a5667c4b9d95da7 /test
parentad87ba262b4ae6b64e31b10ef9bced5168d8e467 (diff)
parent2dde6eb29fa82af61ddba108da42c79cab60f100 (diff)
downloadjquery-once-43af89bfb0d71acf447ab3c21b552facb461da6a.zip
jquery-once-43af89bfb0d71acf447ab3c21b552facb461da6a.tar.gz
jquery-once-43af89bfb0d71acf447ab3c21b552facb461da6a.tar.bz2
Update CoffeeScript source
Diffstat (limited to 'test')
-rw-r--r--test/index.html6
-rw-r--r--test/test.js26
2 files changed, 23 insertions, 9 deletions
diff --git a/test/index.html b/test/index.html
index 038db22..6a0293f 100644
--- a/test/index.html
+++ b/test/index.html
@@ -2,7 +2,7 @@
<html>
<head>
<title>jQuery Once - Test Suite</title>
- <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css">
+ <link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
</head>
<body id="body">
<div id="qunit"></div>
@@ -31,8 +31,8 @@
</div>
- <script src="http://code.jquery.com/jquery-2.1.1.js"></script>
- <script src="http://code.jquery.com/qunit/qunit-1.11.0.js"></script>
+ <script src="../node_modules/jquery/dist/jquery.js"></script>
+ <script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="../jquery.once.js"></script>
<script src="test.js"></script>
</body>
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);