mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 01:56:21 +00:00
Make CLI tests asynchronous.
This commit is contained in:
parent
a456093f13
commit
d7c83613df
@ -8,52 +8,31 @@ CLI test routines for HackMyResume.
|
|||||||
var chai = require('chai')
|
var chai = require('chai')
|
||||||
, should = chai.should()
|
, should = chai.should()
|
||||||
, expect = chai.expect
|
, expect = chai.expect
|
||||||
, HMRMAIN = require('../../dist/cli/main')
|
|
||||||
, CHALK = require('chalk')
|
|
||||||
, FS = require('fs')
|
, FS = require('fs')
|
||||||
, PATH = require('path')
|
, PATH = require('path')
|
||||||
, PKG = require('../../package.json')
|
, EXEC = require('child_process').exec
|
||||||
, STRIPCOLOR = require('stripcolorcodes')
|
|
||||||
, _ = require('underscore')
|
|
||||||
, EXEC = require('child_process').execSync
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var gather = '';
|
|
||||||
var ConsoleLogOrg = console.log;
|
|
||||||
var ProcessExitOrg = process.exit;
|
|
||||||
var commandRetVal = 0;
|
|
||||||
|
|
||||||
// TODO: use sinon
|
|
||||||
// Replacement for process.exit()
|
|
||||||
function MyProcessExit( retVal ) {
|
|
||||||
commandRetVal = retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: use sinon
|
|
||||||
// Replacement for console.log
|
|
||||||
function MyConsoleLog() {
|
|
||||||
var tx = Array.prototype.slice.call(arguments).join(' ');
|
|
||||||
gather += STRIPCOLOR( tx );
|
|
||||||
ConsoleLogOrg.apply(this, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Testing CLI interface', function () {
|
describe('Testing CLI interface', function () {
|
||||||
|
|
||||||
|
this.timeout(5000);
|
||||||
|
|
||||||
// Run a test through the stub, gathering console.log output into "gather"
|
// Run a test through the stub, gathering console.log output into "gather"
|
||||||
// and testing against it.
|
// and testing against it.
|
||||||
function run( args, expErr ) {
|
function run( args, expErr ) {
|
||||||
var title = args;
|
var title = args;
|
||||||
it( 'Testing: "' + title + '"\n\n', function() {
|
it( 'Testing: "' + title + '"\n\n', function( done ) {
|
||||||
try {
|
try {
|
||||||
EXEC('hackmyresume ' + args);
|
EXEC('hackmyresume ' + args, null, function(err,stdo,stde) {
|
||||||
commandRetVal = 0;
|
var errCode = (err && err.code) || 0;
|
||||||
|
errCode.should.equal( parseInt(expErr, 10) );
|
||||||
|
done();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(ex) {
|
catch(ex) {
|
||||||
commandRetVal = ex.status;
|
ex.status.should.equal( parseInt(expErr, 10) );
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
commandRetVal.should.equal( parseInt(expErr, 10) );
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +47,4 @@ describe('Testing CLI interface', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
process.exit = ProcessExitOrg;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
0|new test/sandbox/cli-test/new-empty-resume.fresh.json -f fresh
|
0|new test/sandbox/cli-test/new-empty-resume.fresh.json -f fresh
|
||||||
3|analyze
|
3|analyze
|
||||||
14|analyze doesnt-exist.json
|
14|analyze doesnt-exist.json
|
||||||
|
0|analyze node_modules/fresh-test-resumes/src/fresh/johnny-trouble.json
|
||||||
3|convert
|
3|convert
|
||||||
7|convert doesnt-exist.json
|
7|convert doesnt-exist.json
|
||||||
3|validate
|
3|validate
|
||||||
|
Loading…
Reference in New Issue
Block a user