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')
|
||||
, should = chai.should()
|
||||
, expect = chai.expect
|
||||
, HMRMAIN = require('../../dist/cli/main')
|
||||
, CHALK = require('chalk')
|
||||
, FS = require('fs')
|
||||
, PATH = require('path')
|
||||
, PKG = require('../../package.json')
|
||||
, STRIPCOLOR = require('stripcolorcodes')
|
||||
, _ = require('underscore')
|
||||
, EXEC = require('child_process').execSync
|
||||
, EXEC = require('child_process').exec
|
||||
|
||||
|
||||
|
||||
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 () {
|
||||
|
||||
this.timeout(5000);
|
||||
|
||||
// Run a test through the stub, gathering console.log output into "gather"
|
||||
// and testing against it.
|
||||
function run( args, expErr ) {
|
||||
var title = args;
|
||||
it( 'Testing: "' + title + '"\n\n', function() {
|
||||
it( 'Testing: "' + title + '"\n\n', function( done ) {
|
||||
try {
|
||||
EXEC('hackmyresume ' + args);
|
||||
commandRetVal = 0;
|
||||
EXEC('hackmyresume ' + args, null, function(err,stdo,stde) {
|
||||
var errCode = (err && err.code) || 0;
|
||||
errCode.should.equal( parseInt(expErr, 10) );
|
||||
done();
|
||||
});
|
||||
}
|
||||
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
|
||||
3|analyze
|
||||
14|analyze doesnt-exist.json
|
||||
0|analyze node_modules/fresh-test-resumes/src/fresh/johnny-trouble.json
|
||||
3|convert
|
||||
7|convert doesnt-exist.json
|
||||
3|validate
|
||||
|
Loading…
Reference in New Issue
Block a user