@@ -71,8 +71,10 @@ describe('BaseSchema', () => {
7171 it ( 'invalid' , ( ) => {
7272 expect ( ( ) => {
7373 BaseSchema ( ) . id ( '' )
74- } ) . toThrow (
75- 'id should not be an empty fragment <#> or an empty string <> (e.g. #myId)'
74+ } ) . toThrowError (
75+ new S . FluentSchemaError (
76+ 'id should not be an empty fragment <#> or an empty string <> (e.g. #myId)'
77+ )
7678 )
7779 } )
7880 } )
@@ -116,7 +118,11 @@ describe('BaseSchema', () => {
116118 BaseSchema ( )
117119 . examples ( value )
118120 . valueOf ( ) . examples
119- ) . toThrow ( "'examples' must be an array e.g. ['1', 'one', 'foo']" )
121+ ) . toThrowError (
122+ new S . FluentSchemaError (
123+ "'examples' must be an array e.g. ['1', 'one', 'foo']"
124+ )
125+ )
120126 } )
121127 } )
122128
@@ -185,8 +191,10 @@ describe('BaseSchema', () => {
185191 BaseSchema ( )
186192 . enum ( value )
187193 . valueOf ( ) . examples
188- ) . toThrow (
189- "'enums' must be an array with at least an element e.g. ['1', 'one', 'foo']"
194+ ) . toThrowError (
195+ new S . FluentSchemaError (
196+ "'enums' must be an array with at least an element e.g. ['1', 'one', 'foo']"
197+ )
190198 )
191199 } )
192200 } )
@@ -300,15 +308,19 @@ describe('BaseSchema', () => {
300308 it ( 'not an array' , ( ) => {
301309 expect ( ( ) => {
302310 return BaseSchema ( ) . allOf ( 'test' )
303- } ) . toThrow (
304- "'allOf' must be a an array of FluentSchema rather than a 'string'"
311+ } ) . toThrowError (
312+ new S . FluentSchemaError (
313+ "'allOf' must be a an array of FluentSchema rather than a 'string'"
314+ )
305315 )
306316 } )
307317 it ( 'not an array of FluentSchema' , ( ) => {
308318 expect ( ( ) => {
309319 return BaseSchema ( ) . allOf ( [ 'test' ] )
310- } ) . toThrow (
311- "'allOf' must be a an array of FluentSchema rather than a 'object'"
320+ } ) . toThrowError (
321+ new S . FluentSchemaError (
322+ "'allOf' must be a an array of FluentSchema rather than a 'object'"
323+ )
312324 )
313325 } )
314326 } )
@@ -355,15 +367,19 @@ describe('BaseSchema', () => {
355367 it ( 'not an array' , ( ) => {
356368 expect ( ( ) => {
357369 return BaseSchema ( ) . anyOf ( 'test' )
358- } ) . toThrow (
359- "'anyOf' must be a an array of FluentSchema rather than a 'string'"
370+ } ) . toThrowError (
371+ new S . FluentSchemaError (
372+ "'anyOf' must be a an array of FluentSchema rather than a 'string'"
373+ )
360374 )
361375 } )
362376 it ( 'not an array of FluentSchema' , ( ) => {
363377 expect ( ( ) => {
364378 return BaseSchema ( ) . anyOf ( [ 'test' ] )
365- } ) . toThrow (
366- "'anyOf' must be a an array of FluentSchema rather than a 'object'"
379+ } ) . toThrowError (
380+ new S . FluentSchemaError (
381+ "'anyOf' must be a an array of FluentSchema rather than a 'object'"
382+ )
367383 )
368384 } )
369385 } )
@@ -383,15 +399,19 @@ describe('BaseSchema', () => {
383399 it ( 'not an array' , ( ) => {
384400 expect ( ( ) => {
385401 return BaseSchema ( ) . oneOf ( 'test' )
386- } ) . toThrow (
387- "'oneOf' must be a an array of FluentSchema rather than a 'string'"
402+ } ) . toThrowError (
403+ new S . FluentSchemaError (
404+ "'oneOf' must be a an array of FluentSchema rather than a 'string'"
405+ )
388406 )
389407 } )
390408 it ( 'not an array of FluentSchema' , ( ) => {
391409 expect ( ( ) => {
392410 return BaseSchema ( ) . oneOf ( [ 'test' ] )
393- } ) . toThrow (
394- "'oneOf' must be a an array of FluentSchema rather than a 'object'"
411+ } ) . toThrowError (
412+ new S . FluentSchemaError (
413+ "'oneOf' must be a an array of FluentSchema rather than a 'object'"
414+ )
395415 )
396416 } )
397417 } )
@@ -425,7 +445,7 @@ describe('BaseSchema', () => {
425445 it ( 'invalid' , ( ) => {
426446 expect ( ( ) => {
427447 BaseSchema ( ) . not ( undefined )
428- } ) . toThrow ( "'not' must be a BaseSchema" )
448+ } ) . toThrowError ( new S . FluentSchemaError ( "'not' must be a BaseSchema" ) )
429449 } )
430450 } )
431451 } )
@@ -480,12 +500,16 @@ describe('BaseSchema', () => {
480500 undefined ,
481501 BaseSchema ( ) . description ( 'A User desc' )
482502 )
483- } ) . toThrow ( "'ifClause' must be a BaseSchema" )
503+ } ) . toThrowError (
504+ new S . FluentSchemaError ( "'ifClause' must be a BaseSchema" )
505+ )
484506 } )
485507 it ( 'thenClause' , ( ) => {
486508 expect ( ( ) => {
487509 BaseSchema ( ) . ifThen ( BaseSchema ( ) . id ( 'id' ) , undefined )
488- } ) . toThrow ( "'thenClause' must be a BaseSchema" )
510+ } ) . toThrowError (
511+ new S . FluentSchemaError ( "'thenClause' must be a BaseSchema" )
512+ )
489513 } )
490514 } )
491515 } )
@@ -547,7 +571,9 @@ describe('BaseSchema', () => {
547571 BaseSchema ( ) . description ( 'then' ) ,
548572 BaseSchema ( ) . description ( 'else' )
549573 )
550- } ) . toThrow ( "'ifClause' must be a BaseSchema" )
574+ } ) . toThrowError (
575+ new S . FluentSchemaError ( "'ifClause' must be a BaseSchema" )
576+ )
551577 } )
552578 it ( 'thenClause' , ( ) => {
553579 expect ( ( ) => {
@@ -556,7 +582,9 @@ describe('BaseSchema', () => {
556582 undefined ,
557583 BaseSchema ( ) . description ( 'else' )
558584 )
559- } ) . toThrow ( "'thenClause' must be a BaseSchema" )
585+ } ) . toThrowError (
586+ new S . FluentSchemaError ( "'thenClause' must be a BaseSchema" )
587+ )
560588 } )
561589 it ( 'elseClause' , ( ) => {
562590 expect ( ( ) => {
@@ -565,7 +593,11 @@ describe('BaseSchema', () => {
565593 BaseSchema ( ) . description ( 'then' ) ,
566594 undefined
567595 )
568- } ) . toThrow ( "'elseClause' must be a BaseSchema" )
596+ } ) . toThrowError (
597+ new S . FluentSchemaError (
598+ "'elseClause' must be a BaseSchema or a false boolean value"
599+ )
600+ )
569601 } )
570602 } )
571603 } )
0 commit comments