Skip to content

Commit

Permalink
test: replace toThrowError() with its canonical name toThrow()
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Nov 29, 2022
1 parent 5f2c11c commit e66d1f4
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 64 deletions.
12 changes: 6 additions & 6 deletions src/ArraySchema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('ArraySchema', () => {
})
})
it('invalid', () => {
expect(() => ArraySchema().items('')).toThrowError(
expect(() => ArraySchema().items('')).toThrow(
new S.FluentSchemaError("'items' must be a S or an array of S")
)
})
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('ArraySchema', () => {
})
})
it('invalid', () => {
expect(() => ArraySchema().additionalItems('')).toThrowError(
expect(() => ArraySchema().additionalItems('')).toThrow(
new S.FluentSchemaError("'additionalItems' must be a boolean or a S")
)
})
Expand All @@ -102,7 +102,7 @@ describe('ArraySchema', () => {
ArraySchema()
.contains('')
.valueOf()
).toThrowError(new S.FluentSchemaError("'contains' must be a S"))
).toThrow(new S.FluentSchemaError("'contains' must be a S"))
})
})

Expand All @@ -122,7 +122,7 @@ describe('ArraySchema', () => {
ArraySchema()
.uniqueItems('invalid')
.valueOf()
).toThrowError(
).toThrow(
new S.FluentSchemaError("'uniqueItems' must be a boolean")
)
})
Expand All @@ -144,7 +144,7 @@ describe('ArraySchema', () => {
ArraySchema()
.minItems('3')
.valueOf()
).toThrowError(new S.FluentSchemaError("'minItems' must be a integer"))
).toThrow(new S.FluentSchemaError("'minItems' must be a integer"))
})
})

Expand All @@ -164,7 +164,7 @@ describe('ArraySchema', () => {
ArraySchema()
.maxItems('5')
.valueOf()
).toThrowError(new S.FluentSchemaError("'maxItems' must be a integer"))
).toThrow(new S.FluentSchemaError("'maxItems' must be a integer"))
})
})

Expand Down
38 changes: 19 additions & 19 deletions src/BaseSchema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('BaseSchema', () => {
it('invalid', () => {
expect(() => {
BaseSchema().id('')
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
'id should not be an empty fragment <#> or an empty string <> (e.g. #myId)'
)
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('BaseSchema', () => {
BaseSchema()
.examples(value)
.valueOf().examples
).toThrowError(
).toThrow(
new S.FluentSchemaError(
"'examples' must be an array e.g. ['1', 'one', 'foo']"
)
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('BaseSchema', () => {
expect(() => {
return S.object()
.prop('A', S.string()).required().required()
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'required' has repeated keys, check your calls to .required()"
)
Expand All @@ -170,7 +170,7 @@ describe('BaseSchema', () => {
return S.object()
.prop('A', S.string().required())
.prop('A', S.string().required())
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'required' has repeated keys, check your calls to .required()"
)
Expand All @@ -181,7 +181,7 @@ describe('BaseSchema', () => {
it('root-level required', () => {
expect(() => {
return S.object().required().valueOf()
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'required' has called on root-level schema, check your calls to .required()"
)
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('BaseSchema', () => {
BaseSchema()
.deprecated('somethingNotBoolean')
.valueOf().deprecated
).toThrowError(
).toThrow(
new S.FluentSchemaError(
"'deprecated' must be a boolean value"
)
Expand Down Expand Up @@ -394,7 +394,7 @@ describe('BaseSchema', () => {
BaseSchema()
.enum(value)
.valueOf().examples
).toThrowError(
).toThrow(
new S.FluentSchemaError(
"'enums' must be an array with at least an element e.g. ['1', 'one', 'foo']"
)
Expand Down Expand Up @@ -511,7 +511,7 @@ describe('BaseSchema', () => {
it('not an array', () => {
expect(() => {
return BaseSchema().allOf('test')
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'allOf' must be a an array of FluentSchema rather than a 'string'"
)
Expand All @@ -520,7 +520,7 @@ describe('BaseSchema', () => {
it('not an array of FluentSchema', () => {
expect(() => {
return BaseSchema().allOf(['test'])
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'allOf' must be a an array of FluentSchema rather than a 'object'"
)
Expand Down Expand Up @@ -570,7 +570,7 @@ describe('BaseSchema', () => {
it('not an array', () => {
expect(() => {
return BaseSchema().anyOf('test')
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'anyOf' must be a an array of FluentSchema rather than a 'string'"
)
Expand All @@ -579,7 +579,7 @@ describe('BaseSchema', () => {
it('not an array of FluentSchema', () => {
expect(() => {
return BaseSchema().anyOf(['test'])
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'anyOf' must be a an array of FluentSchema rather than a 'object'"
)
Expand All @@ -602,7 +602,7 @@ describe('BaseSchema', () => {
it('not an array', () => {
expect(() => {
return BaseSchema().oneOf('test')
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'oneOf' must be a an array of FluentSchema rather than a 'string'"
)
Expand All @@ -611,7 +611,7 @@ describe('BaseSchema', () => {
it('not an array of FluentSchema', () => {
expect(() => {
return BaseSchema().oneOf(['test'])
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'oneOf' must be a an array of FluentSchema rather than a 'object'"
)
Expand Down Expand Up @@ -648,7 +648,7 @@ describe('BaseSchema', () => {
it('invalid', () => {
expect(() => {
BaseSchema().not(undefined)
}).toThrowError(new S.FluentSchemaError("'not' must be a BaseSchema"))
}).toThrow(new S.FluentSchemaError("'not' must be a BaseSchema"))
})
})
})
Expand Down Expand Up @@ -703,14 +703,14 @@ describe('BaseSchema', () => {
undefined,
BaseSchema().description('A User desc')
)
}).toThrowError(
}).toThrow(
new S.FluentSchemaError("'ifClause' must be a BaseSchema")
)
})
it('thenClause', () => {
expect(() => {
BaseSchema().ifThen(BaseSchema().id('id'), undefined)
}).toThrowError(
}).toThrow(
new S.FluentSchemaError("'thenClause' must be a BaseSchema")
)
})
Expand Down Expand Up @@ -774,7 +774,7 @@ describe('BaseSchema', () => {
BaseSchema().description('then'),
BaseSchema().description('else')
)
}).toThrowError(
}).toThrow(
new S.FluentSchemaError("'ifClause' must be a BaseSchema")
)
})
Expand All @@ -785,7 +785,7 @@ describe('BaseSchema', () => {
undefined,
BaseSchema().description('else')
)
}).toThrowError(
}).toThrow(
new S.FluentSchemaError("'thenClause' must be a BaseSchema")
)
})
Expand All @@ -796,7 +796,7 @@ describe('BaseSchema', () => {
BaseSchema().description('then'),
undefined
)
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"'elseClause' must be a BaseSchema or a false boolean value"
)
Expand Down
20 changes: 10 additions & 10 deletions src/IntegerSchema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ describe('IntegerSchema', () => {
})
})
it('invalid number', () => {
expect(() => S.integer().minimum('5.1')).toThrowError(
expect(() => S.integer().minimum('5.1')).toThrow(
new S.FluentSchemaError("'minimum' must be a Number")
)
})
it('invalid integer', () => {
expect(() => S.integer().minimum(5.1)).toThrowError(
expect(() => S.integer().minimum(5.1)).toThrow(
new S.FluentSchemaError("'minimum' must be an Integer")
)
})
Expand All @@ -74,12 +74,12 @@ describe('IntegerSchema', () => {
})
})
it('invalid number', () => {
expect(() => S.integer().maximum('5.1')).toThrowError(
expect(() => S.integer().maximum('5.1')).toThrow(
new S.FluentSchemaError("'maximum' must be a Number")
)
})
it('invalid float', () => {
expect(() => S.integer().maximum(5.1)).toThrowError(
expect(() => S.integer().maximum(5.1)).toThrow(
new S.FluentSchemaError("'maximum' must be an Integer")
)
})
Expand All @@ -104,12 +104,12 @@ describe('IntegerSchema', () => {
})
})
it('invalid value', () => {
expect(() => S.integer().multipleOf('5.1')).toThrowError(
expect(() => S.integer().multipleOf('5.1')).toThrow(
new S.FluentSchemaError("'multipleOf' must be a Number")
)
})
it('invalid integer', () => {
expect(() => S.integer().multipleOf(5.1)).toThrowError(
expect(() => S.integer().multipleOf(5.1)).toThrow(
new S.FluentSchemaError("'multipleOf' must be an Integer")
)
})
Expand All @@ -135,12 +135,12 @@ describe('IntegerSchema', () => {
})
})
it('invalid number', () => {
expect(() => S.integer().exclusiveMinimum('5.1')).toThrowError(
expect(() => S.integer().exclusiveMinimum('5.1')).toThrow(
new S.FluentSchemaError("'exclusiveMinimum' must be a Number")
)
})
it('invalid integer', () => {
expect(() => S.integer().exclusiveMinimum(5.1)).toThrowError(
expect(() => S.integer().exclusiveMinimum(5.1)).toThrow(
new S.FluentSchemaError("'exclusiveMinimum' must be an Integer")
)
})
Expand All @@ -165,12 +165,12 @@ describe('IntegerSchema', () => {
})
})
it('invalid number', () => {
expect(() => S.integer().exclusiveMaximum('5.1')).toThrowError(
expect(() => S.integer().exclusiveMaximum('5.1')).toThrow(
new S.FluentSchemaError("'exclusiveMaximum' must be a Number")
)
})
it('invalid integer', () => {
expect(() => S.integer().exclusiveMaximum(5.1)).toThrowError(
expect(() => S.integer().exclusiveMaximum(5.1)).toThrow(
new S.FluentSchemaError("'exclusiveMaximum' must be an Integer")
)
})
Expand Down
4 changes: 2 additions & 2 deletions src/MixedSchema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('MixedSchema', () => {
const types = ''
expect(() => {
S.mixed(types)
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"Invalid 'types'. It must be an array of types. Valid types are string | number | boolean | integer | object | array | null"
)
Expand All @@ -62,7 +62,7 @@ describe('MixedSchema', () => {
const types = ['string', 'invalid']
expect(() => {
S.mixed(types)
}).toThrowError(
}).toThrow(
new S.FluentSchemaError(
"Invalid 'types'. It must be an array of types. Valid types are string | number | boolean | integer | object | array | null"
)
Expand Down
10 changes: 5 additions & 5 deletions src/NumberSchema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('NumberSchema', () => {
})
})
it('invalid value', () => {
expect(() => S.number().minimum('5.1')).toThrowError(
expect(() => S.number().minimum('5.1')).toThrow(
new S.FluentSchemaError("'minimum' must be a Number")
)
})
Expand All @@ -69,7 +69,7 @@ describe('NumberSchema', () => {
})
})
it('invalid value', () => {
expect(() => S.number().maximum('5.1')).toThrowError(
expect(() => S.number().maximum('5.1')).toThrow(
new S.FluentSchemaError("'maximum' must be a Number")
)
})
Expand All @@ -94,7 +94,7 @@ describe('NumberSchema', () => {
})
})
it('invalid value', () => {
expect(() => S.number().multipleOf('5.1')).toThrowError(
expect(() => S.number().multipleOf('5.1')).toThrow(
new S.FluentSchemaError("'multipleOf' must be a Number")
)
})
Expand All @@ -120,7 +120,7 @@ describe('NumberSchema', () => {
})
})
it('invalid value', () => {
expect(() => S.number().exclusiveMinimum('5.1')).toThrowError(
expect(() => S.number().exclusiveMinimum('5.1')).toThrow(
new S.FluentSchemaError("'exclusiveMinimum' must be a Number")
)
})
Expand All @@ -145,7 +145,7 @@ describe('NumberSchema', () => {
})
})
it('invalid value', () => {
expect(() => S.number().exclusiveMaximum('5.1')).toThrowError(
expect(() => S.number().exclusiveMaximum('5.1')).toThrow(
new S.FluentSchemaError("'exclusiveMaximum' must be a Number")
)
})
Expand Down
Loading

0 comments on commit e66d1f4

Please sign in to comment.