From 0f0c399dd5bba24725546fd06f8cd8a6c648c730 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Thu, 7 Jan 2016 13:12:21 -0500 Subject: [PATCH] Update CLI tests. --- test/test-cli.js | 73 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/test/test-cli.js b/test/test-cli.js index 39b464d..a479580 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -1,3 +1,6 @@ +/** +@module test-cli.js +*/ var chai = require('chai') , expect = chai.expect @@ -6,7 +9,8 @@ var chai = require('chai') , _ = require('underscore') , FRESHResume = require('../src/core/fresh-resume') , FCMD = require( '../src/hackmyapi') - , validator = require('is-my-json-valid'); + , validator = require('is-my-json-valid') + , EXTEND = require('../src/utils/extend'); chai.config.includeStack = false; @@ -14,9 +18,6 @@ describe('Testing CLI interface', function () { var _sheet; - function logMsg() { - - } var opts = { format: 'FRESH', @@ -31,38 +32,64 @@ describe('Testing CLI interface', function () { silent: true }; - 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)' ); + 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)' ], + [ '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)' ], + [ 'analyze', [ft + 'jane-fullstacker.json'], [], opts, ' (jane-q-fullstacker|FRESH)' ], + [ 'analyze', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], [], opts2, ' (richard-hendriks|JRS)' ], + [ '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)' ], + [ 'build', + [ ft + 'jane-fullstacker.fresh.json'], + [ sb + 'shouldnt-exist.pdf' ], + EXTEND(true, opts, { theme: 'awesome' }), + ' (jane-q-fullstacker + Awesome + PDF|FRESH)' ] + ].forEach( function(a) { + run.apply( null, a ); + }); + fail( 'new', [], [], opts, " (when a filename isn't specified)" ); - run( 'validate', ['node_modules/fresh-test-resumes/src/jane-fullstacker.fresh.json'], [], opts, ' (jane-q-fullstacker|FRESH)' ); - run( 'validate', ['node_modules/fresh-test-resumes/src/johnny-trouble.fresh.json'], [], opts, ' (johnny-trouble|FRESH)' ); - run( 'validate', ['test/sandbox/new-fresh-resume.json'], [], opts, ' (new-fresh-resume|FRESH)' ); - 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)' ); - 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)' ); - run( 'analyze', ['node_modules/fresh-test-resumes/src/jane-fullstacker.json'], [], opts, ' (jane-q-fullstacker|FRESH)' ); - run( 'analyze', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], [], opts2, ' (richard-hendriks|JRS)' ); + function logMsg() { + + } + - run( 'build', - [ 'node_modules/fresh-test-resumes/src/jane-fullstacker.fresh.json', - 'node_modules/fresh-test-resumes/src/override/jane-fullstacker-override.fresh.json' ], - [ 'test/sandbox/merged/jane-fullstacker-gamedev.fresh.all'], opts, ' (jane-q-fullstacker w/ override|FRESH)' - ); function run( verb, src, dst, opts, msg ) { msg = msg || '.'; it( 'The ' + verb.toUpperCase() + ' command should SUCCEED' + msg, function () { function runIt() { - FCMD.verbs[verb]( src, dst, opts, opts.silent ? logMsg : function(msg){ msg = msg || ''; console.log(msg); } ); + try { + FCMD.verbs[verb]( src, dst, opts, opts.silent ? + logMsg : function(msg){ msg = msg || ''; console.log(msg); } ); + } + catch(ex) { + console.error(ex); + console.error(ex.stack); + throw ex; + } } runIt.should.not.Throw(); }); } + + function fail( verb, src, dst, opts, msg ) { msg = msg || '.'; it( 'The ' + verb.toUpperCase() + ' command should FAIL' + msg, function () { @@ -73,4 +100,6 @@ describe('Testing CLI interface', function () { }); } + + });