Skip to content

Commit f055505

Browse files
newtmitchKent C. Dodds
authored and
Kent C. Dodds
committed
fix: Set default empty object for validate options (#121)
Default option object to keep caller from having to pass empty object during function invocation none
1 parent 381a7c1 commit f055505

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function makeSchema(schemaOptions, schemaExtension) {
6767
return schemaExtension ? schema.concat(schemaExtension) : schema
6868
}
6969

70-
function validate(config, options) {
70+
function validate(config, options = {}) {
7171
const {
7272
// Don't return the config object and throw on error, but just return the validation result
7373
returnValidation, // bool

src/index.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import sinon from 'sinon'
22
import configs from '../test/passing-configs'
33
import failingConfigs from '../test/failing-configs'
44
import { validateRoot as validate, Joi } from './'
5+
const validatecjs = require('./')
56

67
describe('.', () => {
78
let sandbox
@@ -34,6 +35,25 @@ describe('.', () => {
3435
})
3536
})
3637

38+
configs.forEach(({ config, name }) => {
39+
// This is not the multi-compiler, so we explictly pull that configuration out
40+
if (name === 'webpack-multi-compiler') return
41+
42+
it(`validates ${name} using CJS`, () => {
43+
validatecjs(config)
44+
45+
// The success message should have been printed
46+
assert(consoleInfoStub.callCount === 0)
47+
48+
// The error message should not have been printed
49+
if (consoleErrorStub.callCount !== 0) {
50+
throw new Error(consoleErrorStub.args[0])
51+
}
52+
// process.exit should not have been called
53+
assert(processExitStub.callCount === 0)
54+
})
55+
})
56+
3757
failingConfigs.forEach(({ config, name }) => {
3858
it(`throws for ${name}`, () => {
3959
validate(config)

0 commit comments

Comments
 (0)