2016-02-11 17:08:11 +00:00
|
|
|
/**
|
|
|
|
Test routines for the JRSResume 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')
|
|
|
|
, JRSResume = require('../../dist/core/jrs-resume')
|
2016-02-04 23:49:16 +00:00
|
|
|
, ResumeFactory = require('../../dist/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 + ' (JRS)', function() {
|
|
|
|
|
|
|
|
opts.isValid = opts.isValid !== false;
|
|
|
|
|
|
|
|
var _sheet;
|
|
|
|
|
|
|
|
it('should open without throwing an exception', function () {
|
|
|
|
var that = this;
|
|
|
|
function tryOpen() {
|
2016-02-04 23:49:16 +00:00
|
|
|
var res = ResumeFactory.loadOne( path.normalize( path.join( __dirname, '/../resumes/jrs-0.0.0/' + opts.title + '.json' ) ), { objectify: true } );
|
|
|
|
_sheet = res.rez;
|
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.basics.computed.numYears.should.equal( opts.duration );
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should save without throwing an exception', function() {
|
|
|
|
var that = this;
|
|
|
|
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 res = ResumeFactory.loadOne( 'test/sandbox/' + opts.title + '.json', { objectify: true } );
|
|
|
|
_sheet.stringify().should.equal( res.rez.stringify() );
|
2016-01-29 20:23:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should ' + (opts.isValid ? '' : 'NOT ') + 'validate against the JSON Resume schema', function() {
|
|
|
|
var result = _sheet.isValid();
|
|
|
|
// var schemaJson = require('../src/core/resume.json');
|
|
|
|
// 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( opts.isValid );
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var sects = [ 'basics', 'work', 'volunteer', 'skills', 'education', 'publications', 'awards', 'references' ];
|
|
|
|
|
2018-01-25 02:29:24 +00:00
|
|
|
testResume({ title: 'jane-q-fullstacker', duration: 9, sections: sects });
|
2016-01-29 20:23:57 +00:00
|
|
|
testResume({ title: 'jane-incomplete', duration: 0, sections: _.without(sects, 'awards', 'work') });
|
|
|
|
testResume({ title: 'richard-hendriks', duration: 1, sections: sects });
|
|
|
|
testResume({ title: 'empty', duration: 0, sections: [], isValid: false });
|