Skip to content

Commit c0f510b

Browse files
author
carhartl
committed
added very simple tests as a basis for some upcoming refactoring...
1 parent ba23ec9 commit c0f510b

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

‎test/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/qunit/

‎test/test.html‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<link rel="stylesheet" href="qunit/qunit/qunit.css">
6+
<script src="qunit/qunit/qunit.js"></script>
7+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
8+
<script src="../jquery.cookie.js"></script>
9+
<script src="test.js"></script>
10+
<title>jquery.cookie Test Suite</title>
11+
</head>
12+
<body>
13+
<h1 id="qunit-header">jquery.cookie Test Suite</h1>
14+
<h2 id="qunit-banner"></h2>
15+
<div id="qunit-testrunner-toolbar"></div>
16+
<h2 id="qunit-userAgent"></h2>
17+
<ol id="qunit-tests"></ol>
18+
</body>
19+
</html>

‎test/test.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var before = {
2+
setup: function () {
3+
document.cookie = 'c=; expires=' + new Date(0).toUTCString();
4+
}
5+
};
6+
7+
module('read', before);
8+
9+
test('Read', function () {
10+
expect(2);
11+
12+
equals($.cookie('c'), null);
13+
document.cookie = 'c=v';
14+
equals($.cookie('c'), 'v', 'Should read cookie value');
15+
});
16+
17+
module('Write', before);
18+
19+
test('Write', function () {
20+
expect(2);
21+
22+
equals($.cookie('c'), null);
23+
$.cookie('c', 'v');
24+
equals(document.cookie, 'c=v', 'Should write cookie value');
25+
});
26+
27+
module('Delete', before);
28+
29+
test('Delete', function () {
30+
expect(1);
31+
32+
document.cookie = "c=v";
33+
$.cookie('c', null);
34+
equals(document.cookie, '', 'Should delete cookie');
35+
});

0 commit comments

Comments
 (0)