-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added *very basic* test suite (closes #8).
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>CookieJar test suite</title> | ||
<link type="text/css" rel="stylesheet" href="../vendor/jasmine/lib/jasmine.css" /> | ||
<script type="text/javascript" src="../vendor/jasmine/lib/jasmine.js"></script> | ||
<script type="text/javascript" src="../vendor/jasmine/lib/jasmine-html.js"></script> | ||
<script type="text/javascript" src="../build/CookieJar.js"></script> | ||
<script type="text/javascript" src="spec/CookieJarSpec.js"></script> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter()); | ||
jasmine.getEnv().execute(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
describe("CookieJar", function() { | ||
|
||
var name = "name" | ||
, cookie = new CookieJar.Cookie(name, "value"); | ||
|
||
// we want to ensure that the cookie is not set in a previous run of the test suite | ||
window.document.cookie = name + "=_; expires=" + new Date(1).toUTCString(); | ||
|
||
it("should be able to add a cookie", function() { | ||
window.CookieJar.add(cookie); | ||
|
||
expect(window.document.cookie).toEqual(cookie.getName() + '=' + cookie.getValue()); | ||
}); | ||
|
||
it("should get a cookie", function() { | ||
expect(window.CookieJar.get(name).toString()).toEqual(cookie.toString()); | ||
}); | ||
|
||
it("should delete a cookie", function() { | ||
window.CookieJar.remove(name); | ||
|
||
try | ||
{ | ||
window.CookieJar.get(name) | ||
} | ||
catch (execption) | ||
{ | ||
expect(execption.message).toEqual("no cookie named " + name); | ||
} | ||
}); | ||
|
||
}); |