diff --git a/schema/validator.js b/schema/validator.js index b5811dc2..fa6244ff 100644 --- a/schema/validator.js +++ b/schema/validator.js @@ -3,10 +3,10 @@ var ajv = new Ajv({allErrors: true}); var json = require('./schema.json'); module.exports = function validate(data) { - var validSchema = ajv.compile(json); - var valid = validSchema(data); + var ajv = new Ajv(); + var isValid = ajv.validate(json, data); - if(!valid) { + if(!isValid) { throw new Error(ajv.errorsText()); } } diff --git a/test/extract.test.js b/test/extract.test.js index b4e93b2d..fe1fdf91 100644 --- a/test/extract.test.js +++ b/test/extract.test.js @@ -24,9 +24,14 @@ describe("ExtractTextPlugin.extract()", function() { }); it("throws if an incorrect config is passed in", function() { - should.throws(function() { - ExtractTextPlugin.extract({style: 'file.css'}); - }); + should.throws( + function() { + ExtractTextPlugin.extract({style: 'file.css'}); + }, + function(err) { + return err.message === 'data should NOT have additional properties'; + } + ); }); });