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-12 15:48:26 +00:00
|
|
|
describe('jane-doe.json (JRS)', function () {
|
2015-10-26 16:30:00 +00:00
|
|
|
|
|
|
|
var _sheet;
|
|
|
|
|
|
|
|
it('should open without throwing an exception', function () {
|
|
|
|
function tryOpen() {
|
2015-12-12 15:48:26 +00:00
|
|
|
_sheet = new JRSResume().open(
|
|
|
|
path.join( __dirname, 'resumes/jrs/jane-doe.json' ) );
|
2015-10-26 16:30:00 +00:00
|
|
|
}
|
|
|
|
tryOpen.should.not.Throw();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have one or more of each section', function() {
|
|
|
|
expect(
|
|
|
|
(_sheet.basics) &&
|
|
|
|
(_sheet.work && _sheet.work.length > 0) &&
|
|
|
|
(_sheet.skills && _sheet.skills.length > 0) &&
|
|
|
|
(_sheet.education && _sheet.education.length > 0) &&
|
|
|
|
(_sheet.volunteer && _sheet.volunteer.length > 0) &&
|
|
|
|
(_sheet.publications && _sheet.publications.length > 0) &&
|
|
|
|
(_sheet.awards && _sheet.awards.length > 0)
|
|
|
|
).to.equal( true );
|
|
|
|
});
|
|
|
|
|
2015-12-12 15:48:26 +00:00
|
|
|
it('should have a work duration of 7 years', function() {
|
|
|
|
_sheet.basics.computed.numYears.should.equal( 7 );
|
2015-10-26 16:30:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should save without throwing an exception', function(){
|
|
|
|
function trySave() {
|
2015-12-12 15:48:26 +00:00
|
|
|
_sheet.save( 'tests/sandbox/jane-doe.json' );
|
2015-10-26 16:30:00 +00:00
|
|
|
}
|
|
|
|
trySave.should.not.Throw();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not be modified after saving', function() {
|
2015-12-12 15:48:26 +00:00
|
|
|
var savedSheet = new JRSResume().open( 'tests/sandbox/jane-doe.json' );
|
2015-10-26 16:30:00 +00:00
|
|
|
_sheet.stringify().should.equal( savedSheet.stringify() )
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should 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-10-26 16:30:00 +00:00
|
|
|
result.should.equal( true );
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|