2015-10-26 16:30:00 +00:00
|
|
|
|
|
|
|
var chai = require('chai')
|
|
|
|
, expect = chai.expect
|
|
|
|
, should = chai.should()
|
|
|
|
, path = require('path')
|
|
|
|
, _ = require('underscore')
|
2015-11-19 15:39:14 +00:00
|
|
|
, JRSResume = require('../src/core/jrs-resume')
|
2015-10-26 16:30:00 +00:00
|
|
|
, validator = require('is-my-json-valid');
|
|
|
|
|
|
|
|
chai.config.includeStack = false;
|
|
|
|
|
2015-12-24 11:08:45 +00:00
|
|
|
function testResume( opts ) {
|
|
|
|
|
|
|
|
describe( opts.title + ' (JRS)', function() {
|
|
|
|
|
|
|
|
opts.isValid = opts.isValid !== false;
|
2015-10-26 16:30:00 +00:00
|
|
|
|
|
|
|
var _sheet;
|
|
|
|
|
2015-12-24 11:08:45 +00:00
|
|
|
it('should open without throwing an exception', function () {
|
|
|
|
var that = this;
|
2015-10-26 16:30:00 +00:00
|
|
|
function tryOpen() {
|
2015-12-12 15:48:26 +00:00
|
|
|
_sheet = new JRSResume().open(
|
2015-12-24 11:08:45 +00:00
|
|
|
path.join( __dirname, 'resumes/jrs-0.0.0/' + opts.title + '.json' ) );
|
2015-10-26 16:30:00 +00:00
|
|
|
}
|
|
|
|
tryOpen.should.not.Throw();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have one or more of each section', function() {
|
2015-12-24 11:08:45 +00:00
|
|
|
var newObj = _.pick( _sheet, opts.sections );
|
|
|
|
expect( Object.keys(newObj).length ).to.equal( opts.sections.length );
|
2015-10-26 16:30:00 +00:00
|
|
|
});
|
|
|
|
|
2015-12-24 11:08:45 +00:00
|
|
|
it('should have a work duration of ' + opts.duration + ' years', function() {
|
|
|
|
_sheet.basics.computed.numYears.should.equal( opts.duration );
|
2015-10-26 16:30:00 +00:00
|
|
|
});
|
|
|
|
|
2015-12-24 11:08:45 +00:00
|
|
|
it('should save without throwing an exception', function() {
|
|
|
|
var that = this;
|
2015-10-26 16:30:00 +00:00
|
|
|
function trySave() {
|
2015-12-24 11:08:45 +00:00
|
|
|
_sheet.save( 'tests/sandbox/' + opts.title + '.json' );
|
2015-10-26 16:30:00 +00:00
|
|
|
}
|
|
|
|
trySave.should.not.Throw();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not be modified after saving', function() {
|
2015-12-24 11:08:45 +00:00
|
|
|
var savedSheet = new JRSResume().open( 'tests/sandbox/' + opts.title + '.json' );
|
2015-10-26 16:30:00 +00:00
|
|
|
_sheet.stringify().should.equal( savedSheet.stringify() )
|
|
|
|
});
|
|
|
|
|
2015-12-24 11:08:45 +00:00
|
|
|
it('should ' + (opts.isValid ? '' : 'NOT ') + 'validate against the JSON Resume schema', function() {
|
2015-12-12 15:48:26 +00:00
|
|
|
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 ) );
|
2015-10-26 16:30:00 +00:00
|
|
|
result || console.log("\n\nOops, resume didn't validate. " +
|
2015-12-12 15:48:26 +00:00
|
|
|
"Validation errors:\n\n", _sheet.basics.imp.validationErrors, "\n\n");
|
2015-12-24 11:08:45 +00:00
|
|
|
result.should.equal( opts.isValid );
|
2015-10-26 16:30:00 +00:00
|
|
|
});
|
|
|
|
|
2015-12-24 11:08:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var sects = [ 'basics', 'work', 'volunteer', 'skills', 'education', 'publications', 'awards', 'references' ];
|
2015-10-26 16:30:00 +00:00
|
|
|
|
2015-12-24 11:08:45 +00:00
|
|
|
testResume({ title: 'jane-q-fullstacker', duration: 7, sections: sects });
|
|
|
|
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 });
|