@@ -81,5 +81,31 @@ describe('SendMessage utils', () => {
8181 'Error in parsing the "content" field value' ,
8282 ] ) ;
8383 } ) ;
84+
85+ it ( 'should successfully validate when schema references json-schema version draft-07' , ( ) => {
86+ const schema = `{"type":"object","title":"A","description":"A","$id":"https://example.com/A.json",
87+ "$schema":"http://json-schema.org/draft-07/schema#","required":["a"],"properties":{"a":{"type":"number"}}}` ;
88+ expect ( validateBySchema ( '{"a": 6}' , schema , 'key' ) ) . toHaveLength ( 0 ) ;
89+ } ) ;
90+ it ( 'should successfully validate when schema references json-schema version draft-06' , ( ) => {
91+ const schema = `{"type":"object","title":"A","description":"A","$id":"https://example.com/A.json",
92+ "$schema":"http://json-schema.org/draft-06/schema#","required":["a"],"properties":{"a":{"type":"number"}}}` ;
93+ expect ( validateBySchema ( '{"a": 6}' , schema , 'key' ) ) . toHaveLength ( 0 ) ;
94+ } ) ;
95+ it ( 'should successfully validate when schema references json-schema version draft-04' , ( ) => {
96+ const schema = `{"type":"object","title":"A","description":"A","id":"https://example.com/A.json",
97+ "$schema":"http://json-schema.org/draft-04/schema#","required":["a"],"properties":{"a":{"type":"number"}}}` ;
98+ expect ( validateBySchema ( '{"a": 6}' , schema , 'key' ) ) . toHaveLength ( 0 ) ;
99+ } ) ;
100+ it ( 'should successfully validate when schema references json-schema version draft-2019-09' , ( ) => {
101+ const schema = `{"type":"object","title":"A","description":"A","$id":"https://example.com/A.json",
102+ "$schema":"https://json-schema.org/draft/2019-09/schema","required":["a"],"properties":{"a":{"type":"number"}}}` ;
103+ expect ( validateBySchema ( '{"a": 6}' , schema , 'key' ) ) . toHaveLength ( 0 ) ;
104+ } ) ;
105+ it ( 'should successfully validate when schema references json-schema version draft-2020-12' , ( ) => {
106+ const schema = `{"type":"object","title":"A","description":"A","$id":"https://example.com/A.json",
107+ "$schema":"https://json-schema.org/draft/2020-12/schema","required":["a"],"properties":{"a":{"type":"number"}}}` ;
108+ expect ( validateBySchema ( '{"a": 6}' , schema , 'key' ) ) . toHaveLength ( 0 ) ;
109+ } ) ;
84110 } ) ;
85111} ) ;
0 commit comments