Created
January 14, 2016 01:00
-
-
Save tmcw/07e6ea91ed1ac43aa7db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var remark = require('remark'); | |
var expect = require('expect'); | |
var fs = require('fs'); | |
var visit = require('unist-util-visit'); | |
describe('json validity', () => { | |
fs.readdirSync('./content').forEach(function(file) { | |
it('valid ' + file, function() { | |
var content = fs.readFileSync('./content/' + file, 'utf8'); | |
var ast = remark.parse(content); | |
visit(ast, 'code', function(node) { | |
if (node.lang === 'json') { | |
expect(function() { | |
JSON.parse(node.value); | |
}).toNotThrow(null, 'a JSON code block at L:' + | |
node.position.start.line + ' of ' + file + ' was invalid'); | |
} | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment