Permalink
Browse files

ensure that optimized js and css files are generated by build-require…

….js.
  • Loading branch information...
1 parent 311384f commit 1b695f9b9bc32ac703bfbf20ed933ffe64051610 @toolness committed Jan 16, 2013
Showing with 19 additions and 1 deletion.
  1. +19 −1 test/node-tap/test-qunit.js
@@ -2,8 +2,18 @@ var test = require("tap").test;
var rootDir = require('path').resolve(__dirname, '..', '..');
var express = require('express');
var path = require('path');
+var fs = require('fs');
var spawn = require('child_process').spawn;
+function exists(filename) {
+ return fs.existsSync(path.resolve(rootDir, filename));
+}
+
+function rm(filename) {
+ if (exists(filename))
+ fs.unlinkSync(path.resolve(rootDir, filename));
+}
+
function loggedSpawn(command, args, options) {
var process = spawn(command, args, options);
process.stdout.setEncoding('utf8');
@@ -40,10 +50,18 @@ test("unoptimized test suite works", function(t) {
});
test("optimized build and test suite work", function(t) {
- var optimize = loggedSpawn('node', [rootDir + '/bin/build-require.js']);
+ var optimize;
+ var builtJs = 'js/friendlycode-built.js';
+ var builtCss = 'css/friendlycode-built.css';
+
+ rm(builtJs);
+ rm(builtCss);
+ optimize = loggedSpawn('node', [rootDir + '/bin/build-require.js']);
optimize.on('exit', function(status) {
console.log('build-require.js exited with code', status);
t.equal(status, 0, "build-require.js should exit with no errors");
+ t.ok(exists(builtJs), builtJs + " was created");
+ t.ok(exists(builtCss), builtCss + " was created");
runQUnitTests("/test/index-optimized.html", t);
});
});

0 comments on commit 1b695f9

Please sign in to comment.