From df27924ac20d254307aed919408fbafde4397f74 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Wed, 30 Dec 2015 21:07:28 -0500 Subject: [PATCH] Add Johnny Trouble to tests. --- package.json | 3 +- test/test-fresh-sheet.js | 89 +++++++++++++++++++--------------------- test/test-themes.js | 47 ++++++++++----------- 3 files changed, 65 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index 79c689c..bef8d59 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "dependencies": { "colors": "^1.1.2", "copy": "^0.1.3", - "fresh-themes": "~0.9.2-beta", + "fresh-themes": "~0.9.3-beta", "fresca": "~0.2.2", "fs-extra": "^0.24.0", "handlebars": "^4.0.5", @@ -79,6 +79,7 @@ "grunt-contrib-yuidoc": "^0.10.0", "grunt-simple-mocha": "*", "jane-q-fullstacker": "fluentdesk/jane-q-fullstacker", + "johnny-trouble-resume": "fluentdesk/johnny-trouble-resume", "jsonresume-theme-boilerplate": "^0.1.2", "jsonresume-theme-classy": "^1.0.9", "jsonresume-theme-modern": "0.0.18", diff --git a/test/test-fresh-sheet.js b/test/test-fresh-sheet.js index 4d28559..eb2ec7c 100644 --- a/test/test-fresh-sheet.js +++ b/test/test-fresh-sheet.js @@ -9,59 +9,54 @@ var chai = require('chai') chai.config.includeStack = false; -describe('jane-doe.json (FRESH)', function () { +function testResume(opts) { - var _sheet; + describe( opts.title + ' (FRESH)', function () { - it('should open without throwing an exception', function () { - function tryOpen() { - _sheet = new FRESHResume().open( - 'node_modules/jane-q-fullstacker/resume/jane-resume.json' ); - } - tryOpen.should.not.Throw(); - }); + var _sheet; - it('should have one or more of each section', function() { - expect( - //(_sheet.basics) && - _sheet.name && _sheet.info && _sheet.location && _sheet.contact && - (_sheet.employment.history && _sheet.employment.history.length > 0) && - (_sheet.skills && _sheet.skills.list.length > 0) && - (_sheet.education.history && _sheet.education.history.length > 0) && - (_sheet.service.history && _sheet.service.history.length > 0) && - (_sheet.writing && _sheet.writing.length > 0) && - (_sheet.recognition && _sheet.recognition.length > 0) && - (_sheet.samples && _sheet.samples.length > 0) && - (_sheet.references && _sheet.references.length > 0) && - (_sheet.interests && _sheet.interests.length > 0) - ).to.equal( true ); - }); + it('should open without throwing an exception', function () { + function tryOpen() { + _sheet = new FRESHResume().open( opts.path ); + } + tryOpen.should.not.Throw(); + }); - it('should have a work duration of 7 years', function() { - _sheet.computed.numYears.should.equal( 7 ); - }); + it('should have one or more of each section', function() { + var newObj = _.pick( _sheet, opts.sections ); + expect( Object.keys(newObj).length ).to.equal( opts.sections.length ); + }); - it('should save without throwing an exception', function(){ - function trySave() { - _sheet.save( 'test/sandbox/jane-q-fullstacker.json' ); - } - trySave.should.not.Throw(); - }); + it('should have a work duration of ' + opts.duration + ' years', function() { + _sheet.computed.numYears.should.equal( opts.duration ); + }); - it('should not be modified after saving', function() { - var savedSheet = new FRESHResume().open('test/sandbox/jane-q-fullstacker.json'); - _sheet.stringify().should.equal( savedSheet.stringify() ); - }); + it('should save without throwing an exception', function(){ + function trySave() { + _sheet.save( 'test/sandbox/' + opts.title + '.json' ); + } + trySave.should.not.Throw(); + }); - it('should validate against the FRESH resume schema', function() { - var result = _sheet.isValid(); - // var schemaJson = require('fresca'); - // var validate = validator( schemaJson, { verbose: true } ); - // var result = validate( JSON.parse( _sheet.imp.raw ) ); - result || console.log("\n\nOops, resume didn't validate. " + - "Validation errors:\n\n", _sheet.imp.validationErrors, "\n\n"); - result.should.equal( true ); - }); + it('should not be modified after saving', function() { + var savedSheet = new FRESHResume().open('test/sandbox/' + opts.title + '.json'); + _sheet.stringify().should.equal( savedSheet.stringify() ); + }); + + it('should validate against the FRESH resume schema', function() { + var result = _sheet.isValid(); + // var schemaJson = require('fresca'); + // var validate = validator( schemaJson, { verbose: true } ); + // var result = validate( JSON.parse( _sheet.imp.raw ) ); + result || console.log("\n\nOops, resume didn't validate. " + + "Validation errors:\n\n", _sheet.imp.validationErrors, "\n\n"); + result.should.equal( true ); + }); -}); + }); +} + +var sects = [ 'info', 'employment', 'service', 'skills', 'education', 'writing', 'recognition', 'references' ]; +testResume({ title: 'jane-q-fullstacker', path: 'node_modules/jane-q-fullstacker/resume/jane-resume.json', duration: 7, sections: sects }); +testResume({ title: 'johnny-trouble-resume', path: 'node_modules/johnny-trouble-resume/src/johnny-trouble.fresh.json', duration: 3, sections: sects }); diff --git a/test/test-themes.js b/test/test-themes.js index 5a6ee1d..ba9496a 100644 --- a/test/test-themes.js +++ b/test/test-themes.js @@ -12,7 +12,9 @@ var SPAWNWATCHER = require('../src/core/spawn-watch') chai.config.includeStack = false; -describe('Testing themes', function () { +function genThemes( title, src, fmt ) { + + describe('Testing themes against ' + title.toUpperCase() + ' resume ' + '(' + fmt + ')' , function () { var _sheet; @@ -29,11 +31,11 @@ describe('Testing themes', function () { function genTheme( fmt, src, themeName, themeLoc, testTitle ) { themeLoc = themeLoc || themeName; - testTitle = themeName.toUpperCase() + ' theme should generate without throwing an exception'; + testTitle = themeName.toUpperCase() + ' theme (' + fmt + ') should generate without throwing an exception'; it( testTitle, function () { function tryOpen() { //var src = ['node_modules/jane-q-fullstacker/resume/jane-resume.json']; - var dst = ['test/sandbox/' + fmt + '/' + themeName + '/resume.all']; + var dst = ['test/sandbox/' + fmt + '/' + title + '/' + themeName + '/resume.all']; var opts = { theme: themeLoc, format: fmt, @@ -46,28 +48,21 @@ describe('Testing themes', function () { }); } - var src = ['node_modules/jane-q-fullstacker/resume/jane-resume.json']; - genTheme('FRESH', src, 'hello-world'); - genTheme('FRESH', src, 'compact'); - genTheme('FRESH', src, 'modern'); - genTheme('FRESH', src, 'minimist'); - genTheme('FRESH', src, 'awesome'); - genTheme('FRESH', src, 'positive'); - genTheme('FRESH', src, 'jsonresume-theme-boilerplate', 'node_modules/jsonresume-theme-boilerplate' ); - genTheme('FRESH', src, 'jsonresume-theme-sceptile', 'node_modules/jsonresume-theme-sceptile' ); - genTheme('FRESH', src, 'jsonresume-theme-modern', 'node_modules/jsonresume-theme-modern' ); - genTheme('FRESH', src, 'jsonresume-theme-classy', 'node_modules/jsonresume-theme-classy' ); + genTheme(fmt, src, 'hello-world'); + genTheme(fmt, src, 'compact'); + genTheme(fmt, src, 'modern'); + genTheme(fmt, src, 'minimist'); + genTheme(fmt, src, 'awesome'); + genTheme(fmt, src, 'positive'); + genTheme(fmt, src, 'jsonresume-theme-boilerplate', 'node_modules/jsonresume-theme-boilerplate' ); + genTheme(fmt, src, 'jsonresume-theme-sceptile', 'node_modules/jsonresume-theme-sceptile' ); + genTheme(fmt, src, 'jsonresume-theme-modern', 'node_modules/jsonresume-theme-modern' ); + genTheme(fmt, src, 'jsonresume-theme-classy', 'node_modules/jsonresume-theme-classy' ); - src = ['test/resumes/jrs-0.0.0/richard-hendriks.json']; - genTheme('JRS', src, 'hello-world'); - genTheme('JRS', src, 'compact'); - genTheme('JRS', src, 'modern'); - genTheme('JRS', src, 'minimist'); - genTheme('JRS', src, 'awesome'); - genTheme('JRS', src, 'positive'); - genTheme('JRS', src, 'jsonresume-theme-boilerplate', 'node_modules/jsonresume-theme-boilerplate' ); - genTheme('JRS', src, 'jsonresume-theme-sceptile', 'node_modules/jsonresume-theme-sceptile' ); - genTheme('JRS', src, 'jsonresume-theme-modern', 'node_modules/jsonresume-theme-modern' ); - genTheme('JRS', src, 'jsonresume-theme-classy', 'node_modules/jsonresume-theme-classy' ); + }); -}); +} + +genThemes( 'jane-q-fullstacker', ['node_modules/jane-q-fullstacker/resume/jane-resume.json'], 'FRESH' ); +genThemes( 'johnny-trouble', ['node_modules/johnny-trouble-resume/src/johnny-trouble.fresh.json'], 'FRESH' ); +genThemes( 'richard-hendriks', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], 'JRS' );