1 |
|
2 | var chai = require('chai')
|
3 | , expect = chai.expect
|
4 | , should = chai.should()
|
5 | , path = require('path')
|
6 | , _ = require('underscore')
|
7 | , FRESHResume = require('../src/core/fresh-resume')
|
8 | , validator = require('is-my-json-valid');
|
9 |
|
10 | chai.config.includeStack = false;
|
11 |
|
12 | function testResume(opts) {
|
13 |
|
14 | describe( opts.title + ' (FRESH)', function () {
|
15 |
|
16 | var _sheet;
|
17 |
|
18 | it('should open without throwing an exception', function () {
|
19 | function tryOpen() {
|
20 | _sheet = new FRESHResume().open( opts.path );
|
21 | }
|
22 | tryOpen.should.not.Throw();
|
23 | });
|
24 |
|
25 | it('should have one or more of each section', function() {
|
26 | var newObj = _.pick( _sheet, opts.sections );
|
27 | expect( Object.keys(newObj).length ).to.equal( opts.sections.length );
|
28 | });
|
29 |
|
30 | it('should have a work duration of ' + opts.duration + ' years', function() {
|
31 | _sheet.computed.numYears.should.equal( opts.duration );
|
32 | });
|
33 |
|
34 | it('should save without throwing an exception', function(){
|
35 | function trySave() {
|
36 | _sheet.save( 'test/sandbox/' + opts.title + '.json' );
|
37 | }
|
38 | trySave.should.not.Throw();
|
39 | });
|
40 |
|
41 | it('should not be modified after saving', function() {
|
42 | var savedSheet = new FRESHResume().open('test/sandbox/' + opts.title + '.json');
|
43 | _sheet.stringify().should.equal( savedSheet.stringify() );
|
44 | });
|
45 |
|
46 | it('should validate against the FRESH resume schema', function() {
|
47 | var result = _sheet.isValid();
|
48 |
|
49 |
|
50 |
|
51 | result || console.log("\n\nOops, resume didn't validate. " +
|
52 | "Validation errors:\n\n", _sheet.imp.validationErrors, "\n\n");
|
53 | result.should.equal( true );
|
54 | });
|
55 |
|
56 |
|
57 | });
|
58 | }
|
59 |
|
60 | var sects = [ 'info', 'employment', 'service', 'skills', 'education', 'writing', 'recognition', 'references' ];
|
61 | testResume({ title: 'jane-q-fullstacker', path: 'node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json', duration: 7, sections: sects });
|
62 | testResume({ title: 'johnny-trouble-resume', path: 'node_modules/fresh-test-resumes/src/fresh/johnny-trouble.json', duration: 4, sections: sects });
|
63 |
|
64 | sects = [ 'info', 'contact', 'location' ];
|
65 | testResume({ title: 'jane-q-fullstacker A', path: 'node_modules/fresh-test-resumes/src/fresh/override/jane-partial-a.json', duration: 0, sections: sects });
|
66 |
|
67 | sects = [ 'projects', 'social', 'employment', 'education', 'affiliation' ];
|
68 | testResume({ title: 'jane-q-fullstacker B', path: 'node_modules/fresh-test-resumes/src/fresh/override/jane-partial-b.json', duration: 7, sections: sects });
|
69 |
|
70 | sects = [ 'service', 'skills', 'samples', 'writing', 'reading', 'speaking', 'recognition', 'references', 'testimonials', 'languages', 'interests', 'extracurricular', 'governance' ];
|
71 | testResume({ title: 'jane-q-fullstacker C', path: 'node_modules/fresh-test-resumes/src/fresh/override/jane-partial-c.json', duration: 0, sections: sects });
|