1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-25 09:50:11 +00:00
HackMyResume/test/test-cli.js

95 lines
3.4 KiB
JavaScript
Raw Permalink Normal View History

2016-01-07 18:12:21 +00:00
/**
@module test-cli.js
*/
2015-12-21 07:58:16 +00:00
var chai = require('chai')
, expect = chai.expect
, should = chai.should()
, path = require('path')
, _ = require('underscore')
, FRESHResume = require('../src/core/fresh-resume')
2016-01-04 12:23:20 +00:00
, FCMD = require( '../src/hackmyapi')
2016-01-07 18:12:21 +00:00
, validator = require('is-my-json-valid')
, EXTEND = require('../src/utils/extend');
2015-12-21 07:58:16 +00:00
chai.config.includeStack = false;
describe('Testing CLI interface', function () {
var _sheet;
var opts = {
format: 'FRESH',
prettify: true,
silent: false,
assert: true // Causes validation errors to throw exceptions
2015-12-21 07:58:16 +00:00
};
var opts2 = {
format: 'JRS',
prettify: true,
silent: true
};
2016-01-07 18:12:21 +00:00
var sb = 'test/sandbox/';
var ft = 'node_modules/fresh-test-resumes/src/';
[
[ 'new', [sb + 'new-fresh-resume.json'], [], opts, ' (FRESH format)' ],
[ 'new', [sb + 'new-jrs-resume.json'], [], opts2, ' (JRS format)'],
[ 'new', [sb + 'new-1.json', sb + 'new-2.json', sb + 'new-3.json'], [], opts, ' (multiple FRESH resumes)' ],
[ 'new', [sb + 'new-jrs-1.json', sb + 'new-jrs-2.json', sb + 'new-jrs-3.json'], [], opts, ' (multiple JRS resumes)' ],
2016-01-07 21:13:09 +00:00
[ '!new', [], [], opts, " (when a filename isn't specified)" ],
2016-01-07 18:12:21 +00:00
[ 'validate', [ft + 'jane-fullstacker.fresh.json'], [], opts, ' (jane-q-fullstacker|FRESH)' ],
[ 'validate', [ft + 'johnny-trouble.fresh.json'], [], opts, ' (johnny-trouble|FRESH)' ],
[ 'validate', [sb + 'new-fresh-resume.json'], [], opts, ' (new-fresh-resume|FRESH)' ],
[ 'validate', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], [], opts2, ' (richard-hendriks.json|JRS)' ],
[ 'validate', ['test/resumes/jrs-0.0.0/jane-incomplete.json'], [], opts2, ' (jane-incomplete.json|JRS)' ],
[ 'validate', [sb + 'new-1.json', sb + 'new-jrs-resume.json', sb + 'new-1.json', sb + 'new-2.json', sb + 'new-3.json'], [], opts, ' (5|BOTH)' ],
2016-01-07 21:13:09 +00:00
[ 'analyze', [ft + 'jane-fullstacker.fresh.json'], [], opts, ' (jane-q-fullstacker|FRESH)' ],
[ 'analyze', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], [], opts2, ' (richard-hendriks|JRS)' ],
2016-01-07 21:13:09 +00:00
[ 'build', [ ft + 'jane-fullstacker.fresh.json', ft + 'override/jane-fullstacker-override.fresh.json' ], [ sb + 'merged/jane-fullstacker-gamedev.fresh.all'], opts, ' (jane-q-fullstacker w/ override|FRESH)' ],
2016-01-07 21:13:09 +00:00
[ '!build', [ ft + 'jane-fullstacker.fresh.json'], [ sb + 'shouldnt-exist.pdf' ], EXTEND(true, opts, { theme: 'awesome' }), ' (jane-q-fullstacker + Awesome + PDF|FRESH)' ]
2015-12-21 07:58:16 +00:00
].forEach( function(a) {
2015-12-21 07:58:16 +00:00
run.apply( /* The players of */ null, a );
2016-01-07 18:12:21 +00:00
});
2016-01-04 04:18:35 +00:00
2016-01-05 00:45:49 +00:00
2015-12-21 07:58:16 +00:00
function run( verb, src, dst, opts, msg ) {
msg = msg || '.';
var shouldSucceed = true;
if( verb[0] === '!' ) {
verb = verb.substr(1);
shouldSucceed = false;
}
it( 'The ' + verb.toUpperCase() + ' command should ' + (shouldSucceed ? ' SUCCEED' : ' FAIL') + msg, function () {
2015-12-21 07:58:16 +00:00
function runIt() {
2016-01-07 18:12:21 +00:00
try {
FCMD.verbs[verb]( src, dst, opts, opts.silent ?
function(){} : function(msg){ msg = msg || ''; console.log(msg); } );
2016-01-07 18:12:21 +00:00
}
catch(ex) {
console.error(ex);
console.error(ex.stack);
throw ex;
}
2015-12-21 07:58:16 +00:00
}
if( shouldSucceed )
runIt.should.not.Throw();
else
runIt.should.Throw();
2015-12-21 07:58:16 +00:00
});
}
2016-01-07 18:12:21 +00:00
2015-12-21 07:58:16 +00:00
});