2016-02-11 17:08:11 +00:00
|
|
|
/**
|
|
|
|
Test routines for the FRESHResume class.
|
|
|
|
@module test-jrs-sheet.js
|
|
|
|
@license MIT. See LICENSE.md for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-01-29 20:23:57 +00:00
|
|
|
|
|
|
|
var chai = require('chai')
|
|
|
|
, expect = chai.expect
|
|
|
|
, should = chai.should()
|
|
|
|
, path = require('path')
|
|
|
|
, _ = require('underscore')
|
2018-02-14 15:13:48 +00:00
|
|
|
, FRESHResume = require('../../src/core/fresh-resume')
|
|
|
|
, ResumeFactory = require('../../src/core/resume-factory')
|
2016-01-29 20:23:57 +00:00
|
|
|
, validator = require('is-my-json-valid');
|
|
|
|
|
2016-02-11 17:08:11 +00:00
|
|
|
|
|
|
|
|
2016-01-29 20:23:57 +00:00
|
|
|
chai.config.includeStack = false;
|
|
|
|
|
2016-02-11 17:08:11 +00:00
|
|
|
|
|
|
|
|
2016-01-29 20:23:57 +00:00
|
|
|
function testResume(opts) {
|
|
|
|
|
|
|
|
describe( opts.title + ' (FRESH)', function () {
|
|
|
|
|
|
|
|
var _sheet;
|
|
|
|
|
|
|
|
it('should open without throwing an exception', function () {
|
|
|
|
function tryOpen() {
|
2016-02-04 23:49:16 +00:00
|
|
|
var res = ResumeFactory.loadOne( opts.path, { objectify: true } );
|
|
|
|
_sheet = res.rez;
|
|
|
|
//_sheet = new FRESHResume().open( opts.path );
|
2016-01-29 20:23:57 +00:00
|
|
|
}
|
|
|
|
tryOpen.should.not.Throw();
|
|
|
|
});
|
|
|
|
|
|
|
|
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 have a work duration of ' + opts.duration + ' years', function() {
|
|
|
|
_sheet.computed.numYears.should.equal( opts.duration );
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should save without throwing an exception', function(){
|
|
|
|
function trySave() {
|
|
|
|
_sheet.save( 'test/sandbox/' + opts.title + '.json' );
|
|
|
|
}
|
|
|
|
trySave.should.not.Throw();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not be modified after saving', function() {
|
2016-02-04 23:49:16 +00:00
|
|
|
var savedSheet = ResumeFactory.loadOne( 'test/sandbox/' + opts.title + '.json', { objectify: true } );
|
|
|
|
//var savedSheet = new FRESHResume().open('test/sandbox/' + opts.title + '.json');
|
|
|
|
_sheet.stringify().should.equal( savedSheet.rez.stringify() );
|
2016-01-29 20:23:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should validate against the FRESH resume schema', function() {
|
|
|
|
var result = _sheet.isValid();
|
2018-02-02 09:49:26 +00:00
|
|
|
// var schemaJson = require('fresh-resume-schema');
|
2016-01-29 20:23:57 +00:00
|
|
|
// 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' ];
|
2018-01-25 02:29:24 +00:00
|
|
|
testResume({ title: 'jane-q-fullstacker', path: 'node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json', duration: 9, sections: sects });
|
|
|
|
testResume({ title: 'johnny-trouble-resume', path: 'node_modules/fresh-test-resumes/src/fresh/johnny-trouble.json', duration: 6, sections: sects });
|
2016-01-29 20:23:57 +00:00
|
|
|
|
|
|
|
sects = [ 'info', 'contact', 'location' ];
|
|
|
|
testResume({ title: 'jane-q-fullstacker A', path: 'node_modules/fresh-test-resumes/src/fresh/override/jane-partial-a.json', duration: 0, sections: sects });
|
|
|
|
|
|
|
|
sects = [ 'projects', 'social', 'employment', 'education', 'affiliation' ];
|
2018-01-25 02:29:24 +00:00
|
|
|
testResume({ title: 'jane-q-fullstacker B', path: 'node_modules/fresh-test-resumes/src/fresh/override/jane-partial-b.json', duration: 9, sections: sects });
|
2016-01-29 20:23:57 +00:00
|
|
|
|
|
|
|
sects = [ 'service', 'skills', 'samples', 'writing', 'reading', 'speaking', 'recognition', 'references', 'testimonials', 'languages', 'interests', 'extracurricular', 'governance' ];
|
|
|
|
testResume({ title: 'jane-q-fullstacker C', path: 'node_modules/fresh-test-resumes/src/fresh/override/jane-partial-c.json', duration: 0, sections: sects });
|