Permalink
Browse files

Added some base tests and fixed dependencies in package.json

  • Loading branch information...
1 parent 8d9c7d4 commit e3aed2c98dd8ce35ed92f320f37e229feee1e1f9 ncrohn committed Jun 9, 2011
View
1 .gitignore
@@ -0,0 +1 @@
+node_modules
View
1 lib/express-uglify.js
@@ -1,5 +1,4 @@
-
var exports = module.exports;
exports.middleware = require("../lib/middleware");
View
5 lib/filesystem.js
@@ -8,7 +8,8 @@
var fileSystem = module.exports,
fs = require("fs"),
path = require("path"),
- cachePath = "/./.cache";
+ cachePath = "/./.cache",
+ extension = ".ugly";
/*
* Retrieve a file in a non-blocking fashion
@@ -19,7 +20,7 @@ fileSystem.getFile = function(filePath, callback) {
var base = path.basename(filePath),
dir = path.dirname(filePath),
cacheDir = path.normalize(dir+cachePath)+"/",
- cacheFile = cacheDir+base.replace(".js", ".ugly.js");
+ cacheFile = cacheDir+base.replace(".js", extension+".js");
function getCachedFile() {
fs.readFile(cacheFile, "utf-8",
View
6 package.json
@@ -9,5 +9,11 @@
},
"engines": {
"node": ">= 0.2.0"
+ },
+ "dependencies": {
+ "uglify-js": ">= 1.0.2"
+ },
+ "devDependencies": {
+ "express": "2.3.11"
}
}
View
1 test/assets/.cache/test.ugly.js
@@ -0,0 +1 @@
+var test=function(){var a="foo"}
View
3 test/assets/test.js
@@ -0,0 +1,3 @@
+var test = function() {
+ var x = "foo";
+};
View
0 test/assets/test.min.js
No changes.
View
9 test/basic.test.js
@@ -0,0 +1,9 @@
+var assert = require("assert"),
+ expressUglify = require('../lib/express-uglify');
+
+module.exports = {
+ 'Validity': function() {
+
+ assert.eql(1, 1);
+ }
+};
View
22 test/caching.test.js
@@ -0,0 +1,22 @@
+var assert = require("assert"),
+ uglyExpress = require('../lib/express-uglify'),
+ app = require("express").createServer();
+
+app.configure(function() {
+ app.use(uglyExpress.middleware({ src: __dirname + '/assets'}));
+});
+
+
+module.exports = {
+ "Files are being served": function() {
+ assert.response(
+ app, {
+ url: '/test.js', timeout: 500
+ }, function(res) {
+ console.log("Asserting 'test.js' body is 'var test=function(){var a=\"foo\"}'");
+ assert.ok(res.body === 'var test=function(){var a="foo"}', 'Test assert.response() callback');
+
+ console.log(res.headers);
+ });
+ }
+};

0 comments on commit e3aed2c

Please sign in to comment.