Skip to content

Commit

Permalink
fix: Set default empty object for validate options (#121)
Browse files Browse the repository at this point in the history
Default option object to keep caller from having to pass empty object during function invocation

none
  • Loading branch information
newtmitch authored and Kent C. Dodds committed Jul 27, 2016
1 parent 381a7c1 commit f055505
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function makeSchema(schemaOptions, schemaExtension) {
return schemaExtension ? schema.concat(schemaExtension) : schema
}

function validate(config, options) {
function validate(config, options = {}) {
const {
// Don't return the config object and throw on error, but just return the validation result
returnValidation, // bool
Expand Down
20 changes: 20 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import sinon from 'sinon'
import configs from '../test/passing-configs'
import failingConfigs from '../test/failing-configs'
import { validateRoot as validate, Joi } from './'
const validatecjs = require('./')

describe('.', () => {
let sandbox
Expand Down Expand Up @@ -34,6 +35,25 @@ describe('.', () => {
})
})

configs.forEach(({ config, name }) => {
// This is not the multi-compiler, so we explictly pull that configuration out
if (name === 'webpack-multi-compiler') return

it(`validates ${name} using CJS`, () => {
validatecjs(config)

// The success message should have been printed
assert(consoleInfoStub.callCount === 0)

// The error message should not have been printed
if (consoleErrorStub.callCount !== 0) {
throw new Error(consoleErrorStub.args[0])
}
// process.exit should not have been called
assert(processExitStub.callCount === 0)
})
})

failingConfigs.forEach(({ config, name }) => {
it(`throws for ${name}`, () => {
validate(config)
Expand Down

0 comments on commit f055505

Please sign in to comment.