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-01 09:48:20 +00:00
|
|
|
, validator = require('is-my-json-valid');
|
2015-12-21 07:58:16 +00:00
|
|
|
|
|
|
|
chai.config.includeStack = false;
|
|
|
|
|
|
|
|
describe('Testing CLI interface', function () {
|
|
|
|
|
|
|
|
var _sheet;
|
|
|
|
|
|
|
|
function logMsg() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var opts = {
|
|
|
|
//theme: 'compact',
|
|
|
|
format: 'FRESH',
|
|
|
|
prettify: true,
|
2016-01-04 04:18:35 +00:00
|
|
|
silent: false
|
2015-12-21 07:58:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var opts2 = {
|
|
|
|
format: 'JRS',
|
|
|
|
prettify: true,
|
|
|
|
silent: true
|
|
|
|
};
|
|
|
|
|
2015-12-28 09:01:30 +00:00
|
|
|
run( 'new', ['test/sandbox/new-fresh-resume.json'], [], opts, ' (FRESH format)' );
|
|
|
|
run( 'new', ['test/sandbox/new-jrs-resume.json'], [], opts2, ' (JRS format)' );
|
|
|
|
run( 'new', ['test/sandbox/new-1.json', 'test/sandbox/new-2.json', 'test/sandbox/new-3.json'], [], opts, ' (multiple FRESH resumes)' );
|
|
|
|
run( 'new', ['test/sandbox/new-jrs-1.json', 'test/sandbox/new-jrs-2.json', 'test/sandbox/new-jrs-3.json'], [], opts, ' (multiple JRS resumes)' );
|
2015-12-21 07:58:16 +00:00
|
|
|
fail( 'new', [], [], opts, " (when a filename isn't specified)" );
|
|
|
|
|
2015-12-31 23:24:45 +00:00
|
|
|
run( 'validate', ['node_modules/jane-q-fullstacker/resume/jane-resume.json'], [], opts, ' (jane-q-fullstacker|FRESH)' );
|
|
|
|
run( 'validate', ['node_modules/johnny-trouble-resume/src/johnny-trouble.fresh.json'], [], opts, ' (johnny-trouble|FRESH)' );
|
|
|
|
run( 'validate', ['test/sandbox/new-fresh-resume.json'], [], opts, ' (new-fresh-resume|FRESH)' );
|
2016-01-01 20:06:36 +00:00
|
|
|
run( 'validate', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], [], opts2, ' (richard-hendriks.json|JRS)' );
|
|
|
|
run( 'validate', ['test/resumes/jrs-0.0.0/jane-incomplete.json'], [], opts2, ' (jane-incomplete.json|JRS)' );
|
2015-12-31 23:24:45 +00:00
|
|
|
run( 'validate', ['test/sandbox/new-1.json','test/sandbox/new-jrs-resume.json','test/sandbox/new-1.json', 'test/sandbox/new-2.json', 'test/sandbox/new-3.json'], [], opts, ' (5|BOTH)' );
|
2015-12-21 07:58:16 +00:00
|
|
|
|
2016-01-04 04:18:35 +00:00
|
|
|
run( 'analyze', ['node_modules/jane-q-fullstacker/resume/jane-resume.json'], [], opts, ' (jane-q-fullstacker|FRESH)' );
|
|
|
|
run( 'analyze', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], [], opts2, ' (richard-hendriks|JRS)' );
|
|
|
|
|
2015-12-21 07:58:16 +00:00
|
|
|
function run( verb, src, dst, opts, msg ) {
|
|
|
|
msg = msg || '.';
|
|
|
|
it( 'The ' + verb.toUpperCase() + ' command should SUCCEED' + msg, function () {
|
|
|
|
function runIt() {
|
2016-01-04 04:18:35 +00:00
|
|
|
FCMD.verbs[verb]( src, dst, opts, opts.silent ? logMsg : function(msg){ msg = msg || ''; console.log(msg); } );
|
2015-12-21 07:58:16 +00:00
|
|
|
}
|
|
|
|
runIt.should.not.Throw();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function fail( verb, src, dst, opts, msg ) {
|
|
|
|
msg = msg || '.';
|
|
|
|
it( 'The ' + verb.toUpperCase() + ' command should FAIL' + msg, function () {
|
|
|
|
function runIt() {
|
|
|
|
FCMD.verbs[verb]( src, dst, opts, logMsg );
|
|
|
|
}
|
|
|
|
runIt.should.Throw();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|