1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 16:30:11 +00:00
HackMyResume/test/test-converter.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-11-20 13:29:19 +00:00
var chai = require('chai')
, expect = chai.expect
, should = chai.should()
, path = require('path')
, parsePath = require('parse-filepath')
2015-11-20 13:29:19 +00:00
, _ = require('underscore')
, FRESHResume = require('../src/core/fresh-resume')
2016-01-12 23:14:06 +00:00
, JRSResume = require('../src/core/jrs-resume')
2015-11-20 13:29:19 +00:00
, CONVERTER = require('../src/core/convert')
, FS = require('fs')
2015-12-18 20:34:30 +00:00
, MKDIRP = require('mkdirp')
2015-11-20 13:29:19 +00:00
, _ = require('underscore');
chai.config.includeStack = false;
describe('FRESH/JRS converter', function () {
var _sheet;
it('should round-trip from JRS to FRESH to JRS without modifying or losing data', function () {
var fileA = path.join( __dirname, 'resumes/jrs-0.0.0/richard-hendriks.json' );
2016-01-12 23:14:06 +00:00
var fileB = path.join( __dirname, 'sandbox/richard-hendriks.converted.fresh.json' );
var fileC = path.join( __dirname, 'sandbox/richard-hendriks.converted.jrs.json' );
2015-11-20 13:29:19 +00:00
2016-01-12 23:14:06 +00:00
_sheet = new JRSResume().open( fileA );
MKDIRP.sync( parsePath( fileB ).dirname );
2016-01-12 23:14:06 +00:00
_sheet.saveAs( fileB, 'FRESH' );
var freshSheet = new FRESHResume().open( fileB );
freshSheet.saveAs( fileC, 'JRS' );
2015-11-20 13:29:19 +00:00
var rawA = FS.readFileSync( fileA, 'utf8' );
2016-01-12 23:14:06 +00:00
var rawC = FS.readFileSync( fileC, 'utf8' );
2015-11-20 13:29:19 +00:00
var objA = JSON.parse( rawA );
2016-01-12 23:14:06 +00:00
var objC = JSON.parse( rawC );
2015-11-20 13:29:19 +00:00
2016-01-12 23:14:06 +00:00
_.isEqual(objA, objC).should.equal(true);
2015-11-20 13:29:19 +00:00
});
});