From e4a549ed30c476e0ee25f47b284f622863e9ba25 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Fri, 1 Jan 2016 20:26:47 -0500 Subject: [PATCH] Tests: Add ICE detection test. ICE is the internal boilerplate we use to freeze/unfreeze themes when trying to force-feed them Markdown or other formatted data. --- src/utils/file-contains.js | 12 ++++++++++++ test/test-themes.js | 22 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/utils/file-contains.js diff --git a/src/utils/file-contains.js b/src/utils/file-contains.js new file mode 100644 index 0000000..164f311 --- /dev/null +++ b/src/utils/file-contains.js @@ -0,0 +1,12 @@ +/** +Definition of the SyntaxErrorEx class. +@module file-contains.js +*/ + +(function(){ + + module.exports = function( file, needle ) { + return require('fs').readFileSync(file,'utf-8').indexOf( needle ) > -1; + }; + +}()); diff --git a/test/test-themes.js b/test/test-themes.js index c26c7f8..fa10848 100644 --- a/test/test-themes.js +++ b/test/test-themes.js @@ -7,7 +7,10 @@ var SPAWNWATCHER = require('../src/core/spawn-watch') , _ = require('underscore') , FRESHResume = require('../src/core/fresh-resume') , FCMD = require( '../src/hackmycmd') - , validator = require('is-my-json-valid'); + , validator = require('is-my-json-valid') + , READFILES = require('recursive-readdir-sync') + , fileContains = require('../src/utils/file-contains') + , FS = require('fs'); chai.config.includeStack = false; @@ -51,6 +54,23 @@ function genThemes( title, src, fmt ) { } +function folderContains( needle, haystack ) { + return _.some( READFILES( path.join(__dirname, haystack) ), function( absPath ) { + if( FS.lstatSync( absPath ).isFile() ) { + if( fileContains( absPath, needle ) ) { + console.log('Found invalid metadata in ' + absPath); + return true; + } + } + }); +} + genThemes( 'jane-q-fullstacker', ['node_modules/jane-q-fullstacker/resume/jane-resume.json'], 'FRESH' ); genThemes( 'johnny-trouble', ['node_modules/johnny-trouble-resume/src/johnny-trouble.fresh.json'], 'FRESH' ); genThemes( 'richard-hendriks', ['test/resumes/jrs-0.0.0/richard-hendriks.json'], 'JRS' ); + +describe('Verifying generated theme files...', function() { + it('Generated files should not contain ICE.', function() { + expect( folderContains('@@@@', 'sandbox') ).to.be.false; + }); +});