mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 00:10:15 +00:00
Update tests.
This commit is contained in:
parent
88c71f6e9c
commit
43564bf380
@ -73,7 +73,8 @@ describe('Testing CLI interface', function () {
|
||||
it( 'The ' + verb.toUpperCase() + ' command should ' + (shouldSucceed ? ' SUCCEED' : ' FAIL') + msg, function () {
|
||||
function runIt() {
|
||||
try {
|
||||
FCMD.verbs[verb]( src, dst, opts, opts.silent ?
|
||||
var v = new FCMD.verbs[verb]();
|
||||
v.invoke( src, dst, opts, opts.silent ?
|
||||
function(){} : function(msg){ msg = msg || ''; console.log(msg); } );
|
||||
}
|
||||
catch(ex) {
|
||||
|
@ -2,23 +2,33 @@ var chai = require('chai')
|
||||
, expect = chai.expect
|
||||
, HMRMAIN = require('../src/main')
|
||||
, CHALK = require('chalk')
|
||||
, FS = require('fs')
|
||||
, PATH = require('path')
|
||||
, _ = require('underscore');
|
||||
|
||||
// Disable colors for easier output testing
|
||||
CHALK.enabled = false;
|
||||
var gather = '';
|
||||
var ConsoleLogOrg = console.log;
|
||||
var ProcessExitOrg = process.exit;
|
||||
|
||||
describe('Testing Ouput interface', function () {
|
||||
|
||||
var gather = '';
|
||||
var ConsoleLogOrg = console.log;
|
||||
|
||||
|
||||
function MyConsoleLog( msg ) {
|
||||
gather += msg;
|
||||
ConsoleLogOrg.apply(this, arguments);
|
||||
}
|
||||
|
||||
function MyProcessExit() {
|
||||
|
||||
}
|
||||
|
||||
function HackMyResumeStub( args ) {
|
||||
|
||||
console.log = MyConsoleLog;
|
||||
process.exit = MyProcessExit;
|
||||
CHALK.enabled = false;
|
||||
|
||||
try {
|
||||
args.unshift( process.argv[1] );
|
||||
args.unshift( process.argv[0] );
|
||||
@ -28,24 +38,30 @@ describe('Testing Ouput interface', function () {
|
||||
catch( ex ) {
|
||||
require('../src/core/error-handler').err( ex, false );
|
||||
}
|
||||
CHALK.enabled = true;
|
||||
process.exit = ProcessExitOrg;
|
||||
console.log = ConsoleLogOrg;
|
||||
|
||||
}
|
||||
|
||||
function run( title, args, tests ) {
|
||||
it( title, function() {
|
||||
|
||||
gather = '';
|
||||
console.log = MyConsoleLog;
|
||||
HackMyResumeStub( args );
|
||||
console.log = ConsoleLogOrg;
|
||||
|
||||
expect(
|
||||
_.all( tests, function(t) {
|
||||
return gather.indexOf(t) > -1;
|
||||
})
|
||||
).to.equal(true);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
var title = '*** HackMyResume v1.5.2 ***';
|
||||
var feedMe = 'Please feed me a resume in FRESH or JSON Resume format.';
|
||||
var manPage = FS.readFileSync( PATH.resolve( __dirname, '../src/use.txt' ), 'utf8');
|
||||
|
||||
run('HMR should output a help string when no command is specified',
|
||||
[], [ title, 'Please give me a command (BUILD, ANALYZE, VALIDATE, CONVERT, or NEW).' ]);
|
||||
@ -65,5 +81,10 @@ describe('Testing Ouput interface', function () {
|
||||
run('NEW should output a tip when no source is specified',
|
||||
['new'], [ title, 'Please specify the filename of the resume to create.' ]);
|
||||
|
||||
// This will cause the HELP doc to be emitted, followed by an "unknown option --help"
|
||||
// error in the log, based on the way we're calling into HMR. As long as the test
|
||||
// passes, any extraneous error messages can be ignored here.
|
||||
run('HMR should output help doc with --help',
|
||||
['--help'], [ manPage ]);
|
||||
|
||||
});
|
||||
|
@ -9,7 +9,8 @@ var chai = require('chai')
|
||||
, validator = require('is-my-json-valid')
|
||||
, READFILES = require('recursive-readdir-sync')
|
||||
, fileContains = require('../src/utils/file-contains')
|
||||
, FS = require('fs');
|
||||
, FS = require('fs')
|
||||
, CHALK = require('chalk');
|
||||
|
||||
chai.config.includeStack = true;
|
||||
|
||||
@ -34,7 +35,8 @@ function genThemes( title, src, fmt ) {
|
||||
css: 'embed'
|
||||
};
|
||||
try {
|
||||
HMR.verbs.build( src, dst, opts, function(msg) {
|
||||
var v = new HMR.verbs.build();
|
||||
v.invoke( src, dst, opts, function(msg) {
|
||||
msg = msg || '';
|
||||
console.log(msg);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user