@@ -269,7 +269,7 @@ describe('schema', () => {
269269 it ( 'reports pretty enum errors for a string' , ( ) => {
270270 expect ( runSchema ( 'baz' , testSchema ) ) . toEqual ( [
271271 {
272- message : ` String should be equal to one of the allowed values: foo, bar. Did you mean bar?` ,
272+ message : ' String should be equal to one of the allowed values: ` foo`, ` bar` . Did you mean ` bar`?' ,
273273 path : [ ] ,
274274 } ,
275275 ] ) ;
@@ -310,6 +310,31 @@ describe('schema', () => {
310310 ] ) ;
311311 } ) ;
312312 } ) ;
313+
314+ describe ( 'and an enum contains a null' , ( ) => {
315+ const testSchema : JSONSchema6 = {
316+ $schema : `http://json-schema.org/draft-06/schema#` ,
317+ enum : [ 1 , null ] ,
318+ } ;
319+
320+ it ( 'reports pretty enum errors for a string' , ( ) => {
321+ expect ( runSchema ( 'baz' , testSchema ) ) . toEqual ( [
322+ {
323+ message : `String should be equal to one of the allowed values: 1, null` ,
324+ path : [ ] ,
325+ } ,
326+ ] ) ;
327+ } ) ;
328+
329+ it ( 'reports pretty enum errors for a number' , ( ) => {
330+ expect ( runSchema ( 2 , testSchema ) ) . toEqual ( [
331+ {
332+ message : `Number should be equal to one of the allowed values: 1, null` ,
333+ path : [ ] ,
334+ } ,
335+ ] ) ;
336+ } ) ;
337+ } ) ;
313338 } ) ;
314339
315340 test ( 'reports slightly less pretty enum errors for primitive values that are not similar to any values in enum' , ( ) => {
@@ -321,7 +346,7 @@ describe('schema', () => {
321346
322347 expect ( runSchema ( 'three' , testSchema ) ) . toEqual ( [
323348 {
324- message : ` String should be equal to one of the allowed values: foo, bar`,
349+ message : ' String should be equal to one of the allowed values: ` foo`, ` bar`' ,
325350 path : [ ] ,
326351 } ,
327352 ] ) ;
0 commit comments