Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed tests so they work with the new version of expresso

  • Loading branch information...
commit 34034e4dbdf3e00a270a5a20983d73b42baee272 1 parent 7fcb8d0
@chriso authored
View
2  package.json
@@ -18,7 +18,7 @@
"dependencies": {
"soupselect": ">= 0.2.0",
"validator": ">= 0.1.0",
- "expresso": ">= 0.6.2",
+ "expresso": ">= 0.7.0",
"coffee-script": ">= 0.9.4"
},
"scripts": { "test": "expresso test" },
View
5 test/dom.test.js
@@ -1,7 +1,8 @@
var fs = require('fs'),
nodeio = require('../'),
JobClass = nodeio.JobClass,
- job = new JobClass();
+ job = new JobClass(),
+ assert = require('assert');
var dom = __dirname + '/resources/dom.html';
@@ -29,7 +30,7 @@ var dom = __dirname + '/resources/dom.html';
module.exports = {
- 'test #parseHtml()': function(assert) {
+ 'test #parseHtml()': function() {
fs.readFile(dom, 'utf8', function(err, data) {
if (err) throw err;
View
25 test/io.test.js
@@ -1,7 +1,8 @@
var fs = require('fs'),
nodeio = require('../'),
processor = new nodeio.Processor(),
- JobClass = nodeio.JobClass;
+ JobClass = nodeio.JobClass,
+ assert = require('assert');
var lorem = __dirname+'/resources/lorem.txt',
lorem_crlf = __dirname+'/resources/lorem_crlf.txt',
@@ -20,7 +21,7 @@ function createJob(options, methods) {
module.exports = {
- 'test #read()': function(assert) {
+ 'test #read()': function() {
var job = new JobClass();
//Test sync read
@@ -36,7 +37,7 @@ module.exports = {
});
},
- 'test #readLines()': function(assert) {
+ 'test #readLines()': function() {
var job = createJob();
@@ -116,7 +117,7 @@ module.exports = {
},
- 'test #write()': function(assert) {
+ 'test #write()': function() {
var i = 0;
var job = new JobClass();
@@ -136,7 +137,7 @@ module.exports = {
});
},
- 'test where job.input == false': function(assert) {
+ 'test where job.input == false': function() {
var job = createJob({input:true});
assert.equal('function', typeof job.input);
//input() will return as many lines requested (job will run forever)
@@ -146,7 +147,7 @@ module.exports = {
assert.equal(10, job.input(17, 10).length);
},
- 'test where job.input is an array': function(assert) {
+ 'test where job.input is an array': function() {
var job = createJob({input:[0,1,2,3,4]});
assert.equal('function', typeof job.input);
assert.equal('[0,1]', JSON.stringify(job.input(0, 2)));
@@ -155,7 +156,7 @@ module.exports = {
assert.equal(false, job.input(6, 2));
},
- 'test where job.input is a string (file)': function(assert) {
+ 'test where job.input is a string (file)': function() {
var job = createJob({input:lorem});
assert.equal('function', typeof job.input);
@@ -192,7 +193,7 @@ module.exports = {
},
- 'test where job.input is a string (dir)': function(assert) {
+ 'test where job.input is a string (dir)': function() {
//Test specialised case where input is a path to a dir
var job = createJob({recurse:true},{input:test_dir});
assert.equal('function', typeof job.input);
@@ -227,7 +228,7 @@ module.exports = {
},
- 'test where job.input is an unknown string': function(assert) {
+ 'test where job.input is an unknown string': function() {
try {
createJob({input:'xyz897asd'});
assert.ok(false, 'An exception was not thrown when input is an unknown string');
@@ -236,7 +237,7 @@ module.exports = {
}
},
- 'test where job.output is an unknown string': function(assert) {
+ 'test where job.output is an unknown string': function() {
try {
createJob({output:'xyz897asd'});
assert.ok(false, 'An exception was not thrown when output is an unknown string');
@@ -245,7 +246,7 @@ module.exports = {
}
},
- 'test where job.output is a string': function(assert) {
+ 'test where job.output is a string': function() {
var job = createJob({output:output2});
job.output([1,2,3]);
@@ -256,7 +257,7 @@ module.exports = {
},
- 'test newline': function(assert) {
+ 'test newline': function() {
var job = createJob({newline:'\r\n'},{output:output3});
job.output([1,2,3]);
View
20 test/job.test.js
@@ -1,5 +1,6 @@
var nodeio = require('../'),
- processor = new nodeio.Processor();
+ processor = new nodeio.Processor(),
+ assert = require('assert');
function createJob(options, methods) {
if (typeof methods === 'undefined') {
@@ -11,9 +12,10 @@ function createJob(options, methods) {
module.exports = {
- 'test job extend': function(assert) {
+ 'test job extend': function() {
var job = createJob({foo:'bar'}, {testmethod:function(){return 'a';}});
+
assert.equal('bar', job.options.foo);
assert.equal('function', typeof job.testmethod);
assert.equal('a', job.testmethod());
@@ -24,7 +26,7 @@ module.exports = {
assert.equal(false, new_job.testmethod);
assert.equal('function', typeof new_job.testmethodb);
assert.equal('b', new_job.testmethodb());
-
+
//Test calling a parent method
assert.equal('function', typeof new_job.__super__.testmethod);
assert.equal('a', new_job.__super__.testmethod());
@@ -37,7 +39,7 @@ module.exports = {
assert.equal(false, new_job.testmethod);
},
- 'test job running once': function(assert) {
+ 'test job running once': function() {
var job = createJob({input:false});
//input() should return false on the second call
@@ -45,7 +47,7 @@ module.exports = {
assert.ok(job.input() === false);
},
- 'test job emit() as return': function(assert) {
+ 'test job emit() as return': function() {
var job = createJob();
job.run = function() {
@@ -59,7 +61,7 @@ module.exports = {
job.run();
},
- 'test job emit() async': function(assert) {
+ 'test job emit() async': function() {
var job = createJob();
job.run = function() {
@@ -75,7 +77,7 @@ module.exports = {
job.run();
},
- 'test job skip()': function(assert) {
+ 'test job skip()': function() {
var job = createJob();
assert.deepEqual(job.skip, job.finish);
@@ -92,7 +94,7 @@ module.exports = {
job.run();
},
- 'test job validation': function(assert) {
+ 'test job validation': function() {
//Just test bindings, full test suite for validation methods can be found at:
//https://github.com/chriso/node-validator/blob/master/test/validator.test.js
@@ -108,7 +110,7 @@ module.exports = {
job.assert('abc').isInt();
},
- 'test job filtering / sanitization': function(assert) {
+ 'test job filtering / sanitization': function() {
//Just test bindings, full test suite for filter methods can be found at:
//https://github.com/chriso/node-validator/blob/master/test/filter.test.js
View
49 test/processor.test.js
@@ -1,5 +1,6 @@
var nodeio = require('../'),
- processor = new nodeio.Processor();
+ processor = new nodeio.Processor(),
+ assert = require('assert');
function createJob(options, methods) {
if (typeof methods === 'undefined') {
@@ -15,7 +16,7 @@ function startJob(job, callback, capture_output) {
module.exports = {
- 'test running an empty job': function(assert) {
+ 'test running an empty job': function() {
//Prevent the job from looking for STDIN input
var job = createJob({once:true},{input:false});
@@ -24,7 +25,7 @@ module.exports = {
});
},
- 'test running a basic job': function(assert) {
+ 'test running a basic job': function() {
var out = [];
var job = createJob({
@@ -41,7 +42,7 @@ module.exports = {
});
},
- 'test capturing output': function(assert) {
+ 'test capturing output': function() {
var job = createJob({
input: [0,1,2]
});
@@ -51,7 +52,7 @@ module.exports = {
}, true);
},
- 'test emit() async': function(assert) {
+ 'test emit() async': function() {
var out = [];
var job = createJob({
@@ -73,7 +74,7 @@ module.exports = {
});
},
- 'test emitting via return': function(assert) {
+ 'test emitting via return': function() {
var out = [];
var job = createJob({
@@ -93,7 +94,7 @@ module.exports = {
});
},
- 'test skipping on run': function(assert) {
+ 'test skipping on run': function() {
var out = [];
var job = createJob({
@@ -113,7 +114,7 @@ module.exports = {
});
},
- 'test reduce()': function(assert) {
+ 'test reduce()': function() {
var total = 0;
var job = createJob({
@@ -128,7 +129,7 @@ module.exports = {
});
},
- 'test reduce() emitting': function(assert) {
+ 'test reduce() emitting': function() {
var out = [];
var job = createJob({
@@ -146,7 +147,7 @@ module.exports = {
});
},
- 'test reduce() emitting via return': function(assert) {
+ 'test reduce() emitting via return': function() {
var out = [];
var job = createJob({
@@ -164,7 +165,7 @@ module.exports = {
});
},
- 'test job fail()': function(assert) {
+ 'test job fail()': function() {
var out = [];
var job = createJob({
@@ -187,7 +188,7 @@ module.exports = {
});
},
- 'test job fail() emitting via return': function(assert) {
+ 'test job fail() emitting via return': function() {
var out = [];
var job = createJob({
@@ -210,7 +211,7 @@ module.exports = {
});
},
- 'test fail() being called on validation error': function(assert) {
+ 'test fail() being called on validation error': function() {
var out = [];
var job = createJob({
@@ -233,7 +234,7 @@ module.exports = {
});
},
- 'test fail() being called on dom select error': function(assert) {
+ 'test fail() being called on dom select error': function() {
var out = [];
var job = createJob({
@@ -259,7 +260,7 @@ module.exports = {
});
},
- 'test timeout during run()': function(assert) {
+ 'test timeout during run()': function() {
var out = [];
var job = createJob({timeout: 0.1},{
@@ -285,7 +286,7 @@ module.exports = {
});
},
- 'test take op': function(assert) {
+ 'test take op': function() {
var job = createJob({take:3},{
input: [0,1,2],
run: function(data) {
@@ -297,7 +298,7 @@ module.exports = {
startJob(job, function(){});
},
- 'test max op': function(assert) {
+ 'test max op': function() {
var out = [];
var i = 0;
@@ -322,7 +323,7 @@ module.exports = {
startJob(job, function(){});
},
- 'test max op': function(assert) {
+ 'test max op': function() {
var out = [];
var i = 0;
@@ -346,7 +347,7 @@ module.exports = {
startJob(job, function(){});
},
- 'test output with flattening': function(assert) {
+ 'test output with flattening': function() {
var out = [];
var job = createJob({
@@ -366,7 +367,7 @@ module.exports = {
});
},
- 'test output without flattening': function(assert) {
+ 'test output without flattening': function() {
var out = [];
var job = createJob({flatten:false}, {
@@ -386,7 +387,7 @@ module.exports = {
});
},
- 'test input op': function(assert) {
+ 'test input op': function() {
var i = 0;
var job = createJob({input:10},{
@@ -402,7 +403,7 @@ module.exports = {
});
},
- 'test adding input outside of job.input()': function(assert) {
+ 'test adding input outside of job.input()': function() {
var i = 0, out = [];
var job = createJob({input:10},{
@@ -425,7 +426,7 @@ module.exports = {
});
},
- 'test global timeout': function(assert) {
+ 'test global timeout': function() {
var out = [];
var job = createJob({global_timeout:0.2}, {
@@ -442,7 +443,7 @@ module.exports = {
});
},
- 'test the recurse op': function(assert) {
+ 'test the recurse op': function() {
//Test specialised case where input is a path to a dir
var job = createJob({recurse:true}, {input:__dirname+'/resources/test_dir_input'});
View
15 test/request.test.js
@@ -1,7 +1,8 @@
var nodeio = require('../'),
processor = new nodeio.Processor(),
http = require('http'),
- JobClass = nodeio.JobClass;
+ JobClass = nodeio.JobClass,
+ assert = require('assert');
var job = new JobClass();
@@ -18,7 +19,7 @@ job.fail = function(input, status) {
module.exports = {
- 'test GET request': function(assert) {
+ 'test GET request': function() {
var server = http.createServer(function (req, res) {
res.writeHead(200,{'Content-Type': 'text/plain'});
@@ -41,7 +42,7 @@ module.exports = {
}, 1000);
},
- 'test GET request with custom headers': function(assert) {
+ 'test GET request with custom headers': function() {
var server = http.createServer(function (req, res) {
if (req.headers.foo === 'bar') {
@@ -68,7 +69,7 @@ module.exports = {
}, 1000);
},
- 'test GET request with pre-parse callback': function(assert) {
+ 'test GET request with pre-parse callback': function() {
var server = http.createServer(function (req, res) {
res.writeHead(200,{'Content-Type': 'text/plain'});
@@ -95,7 +96,7 @@ module.exports = {
}, 1000);
},
- 'test POST request': function(assert) {
+ 'test POST request': function() {
var server = http.createServer(function (req, res) {
var data = '';
@@ -127,7 +128,7 @@ module.exports = {
}, 1000);
},
- 'test GET request returning the dom': function(assert) {
+ 'test GET request returning the dom': function() {
var server = http.createServer(function (req, res) {
res.writeHead(200,{'Content-Type': 'text/plain'});
@@ -151,7 +152,7 @@ module.exports = {
}, 1000);
},
- 'test POST request returning the dom': function(assert) {
+ 'test POST request returning the dom': function() {
var server = http.createServer(function (req, res) {
var data = '';
View
7 test/spawn.test.js
@@ -1,5 +1,6 @@
var nodeio = require('../'),
- processor = new nodeio.Processor();
+ processor = new nodeio.Processor(),
+ assert = require('assert');
function createJob(options, methods) {
if (typeof methods === 'undefined') {
@@ -10,7 +11,7 @@ function createJob(options, methods) {
}
module.exports = {
- 'test job.spawn()': function(assert) {
+ 'test job.spawn()': function() {
var job = createJob();
job.spawn('pwd', function(err, stdout, stderr) {
assert.isNull(err);
@@ -29,7 +30,7 @@ module.exports = {
});
},
- 'test job.exec()': function(assert) {
+ 'test job.exec()': function() {
var job = createJob();
job.exec('pwd', function(err, stdout, stderr) {
assert.isNull(err);
Please sign in to comment.
Something went wrong with that request. Please try again.