Skip to content

Commit

Permalink
Added simple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mekwall committed Jul 13, 2011
1 parent d0bac47 commit a251f78
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/app.js
@@ -0,0 +1,69 @@
var tobi = require('tobi'),
express = require('express'),
resmin = require('../index.js'),
app = express.createServer();

var resminConfig = {
js: {
"all": [
"//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js",
"//ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js",
"/js/foo.js",
"/js/bar.js",
"/js/baz.js"
]
},
css: {
"all": [
"//fonts.googleapis.com/css?family=Indie+Flower:regular&v1",
"//fonts.googleapis.com/css?family=Inconsolata:regular&v1",
"/css/foo.css",
"/css/bar.css",
"/css/baz.less"
]
}
};

app.configure(function(){
app.use(express.logger());
app.use(express.bodyParser());
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
resminConfig.merge = true;
resminConfig.minify = true;
resminConfig.gzip = true;
app.use(resmin.middleware(__dirname + '/public', resminConfig));
});

app.dynamicHelpers(resmin.dynamicHelper);

app.get('/', function(req, res) {
res.render('index');
});

var browser = tobi.createBrowser(app);
browser.get('/', function(res, $){
res.should.have.status(200);
res.should.not.have.status(500);
res.should.have.header('Content-Type', 'text/html; charset=utf-8');

var css = $("ul.css"),
js = $("ul.js");

css.should.have.many('li');
js.should.have.many('li');

console.log("CSS files:");
css.find("li").each(function(i,elm){
console.log(elm.innerHTML);
});

console.log("JavaScript files:");
js.find("li").each(function(i,elm){
console.log(elm.innerHTML);
});

console.log("All tests passed!");

app.close();
});
20 changes: 20 additions & 0 deletions tests/package.json
@@ -0,0 +1,20 @@
{
"name" : "resmin-tests",
"version" : "0.0.1",
"author" : "Marcus Ekwall",
"description" : "Test suite for resmin",
"homepage" : "https://github.com/mekwall/node-resmin",
"repository": {
"type": "git",
"url": "git://github.com/mekwall/node-resmin.git"
},
"engines" : { "node" : ">= 0.4.x" },
"main" : "./app.js",
"dependencies" : {
"express": ">= 2.4.2",
"jade": ">= 0.12.4",
"tobi": ">= 0.3.0",
"less": ">= 1.1.2",
"zombie": ">= 0.0.1"
}
}
Empty file added tests/public/css/bar.css
Empty file.
23 changes: 23 additions & 0 deletions tests/public/css/baz.less
@@ -0,0 +1,23 @@
@color: #4D926F;

#header {
color: @color;
}

h2 {
color: @color;
}

.rounded-corners (@radius: 5px) {
border-radius: @radius;
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
}

#header {
.rounded-corners;
}

#footer {
.rounded-corners(10px);
}
Empty file added tests/public/css/foo.css
Empty file.
8 changes: 8 additions & 0 deletions tests/public/js/bar.js
@@ -0,0 +1,8 @@
var hello;
var world;
var one;
var two;
var three;
function bar (alpha, beta, gamma) {
console.log("Hello world!");
}
5 changes: 5 additions & 0 deletions tests/public/js/baz.js
@@ -0,0 +1,5 @@
(function(){
function baz () {
console.log("Hello world!");
}
})();
3 changes: 3 additions & 0 deletions tests/public/js/foo.js
@@ -0,0 +1,3 @@
function foo () {
console.log("Hello world!");
}
9 changes: 9 additions & 0 deletions tests/views/index.jade
@@ -0,0 +1,9 @@
h1 Hello world!

ul.css
- each url in resmin.css.all
li= url

ul.js
- each url in resmin.js.all
li= url
11 changes: 11 additions & 0 deletions tests/views/layout.jade
@@ -0,0 +1,11 @@
!!! 5
html
head
title resmin test suite
//- Stylesheets
- each url in resmin.css.all
link(rel='stylesheet', href=url)
//- Scripts
- each url in resmin.js.all
script(src=url)
body!= body

0 comments on commit a251f78

Please sign in to comment.