Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some unit tests

  • Loading branch information...
commit 1410be7ddb2bac4e9838f966b19226716fbb9f1c 1 parent 234db4f
@Raynos authored
Showing with 36 additions and 1 deletion.
  1. +2 −1  package.json
  2. +34 −0 test/test.js
View
3  package.json
@@ -29,7 +29,8 @@
"tap": "0.2.5",
"routes": "~0.1.1",
"stylus": "~0.28.1",
- "nib": "~0.7.0"
+ "nib": "~0.7.0",
+ "test-server": "0.0.1"
},
"licenses": [
{
View
34 test/test.js
@@ -0,0 +1,34 @@
+var test = require("testling")
+ , testServer = require("test-server")
+ , routilStatic = require("..")
+ , $static = routilStatic({
+ uri: __dirname
+ })
+ , router = new require("routes").Router()
+
+router.addRoute("/*", $static)
+
+testServer(handleRequest, startTests)
+
+function handleRequest(req, res) {
+ var route = router.match(req.url)
+
+ route.fn(req, res, route.params, route.splats)
+}
+
+function startTests(request, done) {
+ test("getting file works", function (t) {
+ request("/test.js", function (err, res, body) {
+ t.equal(err, null, "error is not null")
+
+ t.equal(res.headers["content-type"], "text/javascript")
+ t.ok(res.headers.etag)
+
+ t.ok(body.indexOf("var $static = routilStatic"))
+
+ t.end()
+ })
+ })
+
+ .on("end", done)
+}
Please sign in to comment.
Something went wrong with that request. Please try again.