@@ -643,36 +643,18 @@ describe("Error messages", async () => {
643643 } ] ) ;
644644 } ) ;
645645
646- test ( "format: email (draft-2020-12)" , async ( ) => {
646+ const dialects = [
647+ { name : "draft-2020-12" , schema : "https://json-schema.org/draft/2020-12/schema" } ,
648+ { name : "draft-2019-09" , schema : "https://json-schema.org/draft/2019-09/schema" } ,
649+ { name : "draft-07" , schema : "http://json-schema.org/draft-07/schema" } ,
650+ { name : "draft-06" , schema : "http://json-schema.org/draft-06/schema" } ,
651+ { name : "draft-04" , schema : "http://json-schema.org/draft-04/schema" }
652+ ] ;
653+
654+ for ( const { name, schema } of dialects ) {
655+ test ( `format: email (${ name } )` , async ( ) => {
647656 registerSchema ( {
648- $schema : "https://json-schema.org/draft/2020-12/schema" ,
649- format : "email"
650- } , schemaUri ) ;
651-
652- const instance = "not-an-email" ;
653- const output = {
654- valid : false ,
655- errors : [
656- {
657- absoluteKeywordLocation : "https://example.com/main#/format" ,
658- instanceLocation : "#"
659- }
660- ]
661- } ;
662-
663- const result = await betterJsonSchemaErrors ( output , schemaUri , instance ) ;
664- expect ( result . errors ) . to . eql ( [
665- {
666- schemaLocation : "https://example.com/main#/format" ,
667- instanceLocation : "#" ,
668- message : localization . getFormatErrorMessage ( "email" )
669- }
670- ] ) ;
671- } ) ;
672-
673- test ( "format: email (draft-2019-09)" , async ( ) => {
674- registerSchema ( {
675- $schema : "https://json-schema.org/draft/2019-09/schema" ,
657+ $schema : schema ,
676658 format : "email"
677659 } , schemaUri ) ;
678660
@@ -688,33 +670,7 @@ describe("Error messages", async () => {
688670 } ;
689671
690672 const result = await betterJsonSchemaErrors ( output , schemaUri , instance ) ;
691- expect ( result . errors ) . to . eql ( [
692- {
693- schemaLocation : "https://example.com/main#/format" ,
694- instanceLocation : "#" ,
695- message : localization . getFormatErrorMessage ( "email" )
696- }
697- ] ) ;
698- } ) ;
699-
700- test ( "format: email (draft-07)" , async ( ) => {
701- registerSchema ( {
702- $schema : "http://json-schema.org/draft-07/schema" ,
703- format : "email"
704- } , schemaUri ) ;
705-
706- const instance = "not-an-email" ;
707- const output = {
708- valid : false ,
709- errors : [
710- {
711- absoluteKeywordLocation : "https://example.com/main#/format" ,
712- instanceLocation : "#"
713- }
714- ]
715- } ;
716673
717- const result = await betterJsonSchemaErrors ( output , schemaUri , instance ) ;
718674 expect ( result . errors ) . to . eql ( [
719675 {
720676 schemaLocation : "https://example.com/main#/format" ,
@@ -723,63 +679,7 @@ describe("Error messages", async () => {
723679 }
724680 ] ) ;
725681 } ) ;
726-
727- test ( "format: email (draft-06)" , async ( ) => {
728- registerSchema ( {
729- $schema : "http://json-schema.org/draft-06/schema" ,
730- format : "email"
731- } , schemaUri ) ;
732-
733- const instance = "not-an-email" ;
734- const output = {
735- valid : false ,
736- errors : [
737- {
738- absoluteKeywordLocation : "https://example.com/main#/format" ,
739- instanceLocation : "#"
740- }
741- ]
742- } ;
743-
744- const result = await betterJsonSchemaErrors ( output , schemaUri , instance ) ;
745-
746- expect ( result . errors ) . to . eql ( [
747- {
748- schemaLocation : "https://example.com/main#/format" ,
749- instanceLocation : "#" ,
750- message : localization . getFormatErrorMessage ( "email" )
751- }
752- ] ) ;
753- } ) ;
754-
755- test ( "format: email (draft-04)" , async ( ) => {
756- registerSchema ( {
757- $schema : "http://json-schema.org/draft-04/schema" ,
758- format : "email"
759- } , schemaUri ) ;
760-
761- const instance = "not-an-email" ;
762- const output = {
763- valid : false ,
764- errors : [
765- {
766- absoluteKeywordLocation : "https://example.com/main#/format" ,
767- instanceLocation : "#"
768- }
769- ]
770- } ;
771-
772- const result = await betterJsonSchemaErrors ( output , schemaUri , instance ) ;
773-
774- expect ( result . errors ) . to . eql ( [
775- {
776- schemaLocation : "https://example.com/main#/format" ,
777- instanceLocation : "#" ,
778- message : localization . getFormatErrorMessage ( "email" )
779- }
780- ] ) ;
781- } ) ;
782-
682+ }
783683 test ( "pattern" , async ( ) => {
784684 registerSchema ( {
785685 $schema : "https://json-schema.org/draft/2020-12/schema" ,
0 commit comments