Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sam Breed
committed
Oct 28, 2011
0 parents
commit 207dfad
Showing
7 changed files
with
1,589 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,24 @@ | ||
var http = require('http'), | ||
url = require('url'), | ||
path = require('path'), | ||
fs = require('fs'); | ||
|
||
http.createServer(function (request, response) { | ||
var uri = url.parse(request.url).pathname, | ||
filename = path.join(process.cwd(), uri); | ||
|
||
fs.readFile(filename, 'binary', function (err, file) { | ||
if (err) { | ||
response.writeHead(500, { 'Content-Type': 'text/plain' }); | ||
response.write(err + '\n'); | ||
response.end(); | ||
return; | ||
} | ||
|
||
response.writeHead(200); | ||
response.write(file, 'utf-8'); | ||
response.end(); | ||
}); | ||
}).listen(8124, '127.0.0.1'); | ||
|
||
console.log('Server running at http://127.0.0.1:8124/'); |
Binary file not shown.
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,69 @@ | ||
if( typeof _.cookie == "undefined" && Object.prototype.toString.call( _ ) == "[object Function]" ) { | ||
_ = { cookie: _ }; | ||
} | ||
|
||
var before = { | ||
setup: function () { | ||
var cookies = document.cookie.split('; ') | ||
for (var i = 0, c; (c = (cookies)[i]) && (c = c.split('=')[0]); i++) { | ||
document.cookie = c + '=; expires=' + new Date(0).toUTCString(); | ||
} | ||
} | ||
}; | ||
|
||
|
||
module('read', before); | ||
|
||
test('simple value', 1, function () { | ||
document.cookie = 'c=v'; | ||
equals(_.cookie('c'), 'v', 'should return value'); | ||
}); | ||
|
||
test('not existing', 1, function () { | ||
equals(_.cookie('whatever'), null, 'should return null'); | ||
}); | ||
|
||
test('decode', 1, function () { | ||
document.cookie = encodeURIComponent(' c') + '=' + encodeURIComponent(' v'); | ||
equals(_.cookie(' c'), ' v', 'should decode key and value'); | ||
}); | ||
|
||
test('raw: true', 1, function () { | ||
document.cookie = 'c=%20v'; | ||
equals(_.cookie('c', { raw: true }), '%20v', 'should not decode'); | ||
}); | ||
|
||
|
||
module('write', before); | ||
|
||
test('String primitive', 1, function () { | ||
_.cookie('c', 'v'); | ||
equals(document.cookie, 'c=v', 'should write value'); | ||
}); | ||
|
||
test('String object', 1, function () { | ||
_.cookie('c', new String('v')); | ||
equals(document.cookie, 'c=v', 'should write value'); | ||
}); | ||
|
||
test('return', 1, function () { | ||
equals(_.cookie('c', 'v'), 'c=v', 'should return written cookie string'); | ||
}); | ||
|
||
test('raw: true', 1, function () { | ||
equals(_.cookie('c', ' v', { raw: true }).split('=')[1], | ||
' v', 'should not encode'); | ||
}); | ||
|
||
|
||
module('delete', before); | ||
|
||
test('delete', function () { | ||
document.cookie = 'c=v'; | ||
_.cookie('c', null); | ||
//equals(document.cookie, '', 'should delete with null as value'); | ||
|
||
//document.cookie = 'c=v'; | ||
//_.cookie('c', undefined); | ||
//equals(document.cookie, '', 'should delete with undefined as value'); | ||
}); |
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,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>QUnit Tests</title> | ||
<link rel="stylesheet" href="qunit/qunit.css" media="screen"> | ||
|
||
<!-- reference your own javascript files here --> | ||
|
||
|
||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | ||
<script src="http://documentcloud.github.com/underscore/underscore-min.js" type="text/javascript" charset="utf-8"></script> | ||
<script src="../underscore.cookie.js"></script> | ||
|
||
|
||
<!-- test runner files --> | ||
<script src="qunit/qunit.js"></script> | ||
<script src="cookie.js"></script> | ||
|
||
|
||
|
||
</head> | ||
<body class="flora"> | ||
<h1 id="qunit-header">QUnit Test Suite</h1> | ||
<h2 id="qunit-banner"></h2> | ||
<div id="qunit-testrunner-toolbar"></div> | ||
<h2 id="qunit-userAgent"></h2> | ||
<ol id="qunit-tests"></ol> | ||
<div id="qunit-fixture">test markup</div> | ||
</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,148 @@ | ||
/** Font Family and Sizes */ | ||
|
||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { | ||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; | ||
} | ||
|
||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } | ||
#qunit-tests { font-size: smaller; } | ||
|
||
|
||
/** Resets */ | ||
|
||
#qunit-tests, #qunit-tests li ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
|
||
/** Header */ | ||
|
||
#qunit-header { | ||
padding: 0.5em 0 0.5em 1em; | ||
|
||
color: #fff; | ||
text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px; | ||
background-color: #0d3349; | ||
|
||
border-radius: 15px 15px 0 0; | ||
-moz-border-radius: 15px 15px 0 0; | ||
-webkit-border-top-right-radius: 15px; | ||
-webkit-border-top-left-radius: 15px; | ||
} | ||
|
||
#qunit-banner { | ||
height: 5px; | ||
} | ||
|
||
#qunit-testrunner-toolbar { | ||
padding: 0em 0 0.5em 2em; | ||
} | ||
|
||
#qunit-userAgent { | ||
padding: 0.5em 0 0.5em 2.5em; | ||
background-color: #2b81af; | ||
color: #fff; | ||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; | ||
} | ||
|
||
|
||
/** Tests: Pass/Fail */ | ||
|
||
#qunit-tests { | ||
list-style-position: inside; | ||
} | ||
|
||
#qunit-tests li { | ||
padding: 0.4em 0.5em 0.4em 2.5em; | ||
border-bottom: 1px solid #fff; | ||
list-style-position: inside; | ||
} | ||
|
||
#qunit-tests li strong { | ||
cursor: pointer; | ||
} | ||
|
||
#qunit-tests li ol { | ||
margin-top: 0.5em; | ||
padding: 0.5em; | ||
|
||
background-color: #fff; | ||
|
||
border-radius: 15px; | ||
-moz-border-radius: 15px; | ||
-webkit-border-radius: 15px; | ||
|
||
box-shadow: inset 0px 2px 13px #999; | ||
-moz-box-shadow: inset 0px 2px 13px #999; | ||
-webkit-box-shadow: inset 0px 2px 13px #999; | ||
} | ||
|
||
#qunit-tests li li { | ||
margin: 0.5em; | ||
padding: 0.4em 0.5em 0.4em 0.5em; | ||
background-color: #fff; | ||
border-bottom: none; | ||
list-style-position: inside; | ||
} | ||
|
||
/*** Passing Styles */ | ||
|
||
#qunit-tests li li.pass { | ||
color: #5E740B; | ||
background-color: #fff; | ||
border-left: 26px solid #C6E746; | ||
} | ||
|
||
#qunit-tests li.pass { color: #528CE0; background-color: #D2E0E6; } | ||
#qunit-tests li.pass span.test-name { color: #366097; } | ||
|
||
#qunit-tests li li.pass span.test-actual, | ||
#qunit-tests li li.pass span.test-expected { color: #999999; } | ||
|
||
strong b.pass { color: #5E740B; } | ||
|
||
#qunit-banner.qunit-pass { background-color: #C6E746; } | ||
|
||
/*** Failing Styles */ | ||
|
||
#qunit-tests li li.fail { | ||
color: #710909; | ||
background-color: #fff; | ||
border-left: 26px solid #EE5757; | ||
} | ||
|
||
#qunit-tests li.fail { color: #000000; background-color: #EE5757; } | ||
#qunit-tests li.fail span.test-name, | ||
#qunit-tests li.fail span.module-name { color: #000000; } | ||
|
||
#qunit-tests li li.fail span.test-actual { color: #EE5757; } | ||
#qunit-tests li li.fail span.test-expected { color: green; } | ||
|
||
strong b.fail { color: #710909; } | ||
|
||
#qunit-banner.qunit-fail, | ||
#qunit-testrunner-toolbar { background-color: #EE5757; } | ||
|
||
|
||
/** Footer */ | ||
|
||
#qunit-testresult { | ||
padding: 0.5em 0.5em 0.5em 2.5em; | ||
|
||
color: #2b81af; | ||
background-color: #D2E0E6; | ||
|
||
border-radius: 0 0 15px 15px; | ||
-moz-border-radius: 0 0 15px 15px; | ||
-webkit-border-bottom-right-radius: 15px; | ||
-webkit-border-bottom-left-radius: 15px; | ||
} | ||
|
||
/** Fixture */ | ||
|
||
#qunit-fixture { | ||
position: absolute; | ||
top: -10000px; | ||
left: -10000px; | ||
} |
Oops, something went wrong.