11
2+ import { Call } from "../coverage" ;
23import JsonSchemaFakerRule from "./json-schema-faker-rule" ;
34
45describe ( "JsonSchemaFakerRule" , ( ) => {
@@ -37,7 +38,7 @@ describe("JsonSchemaFakerRule", () => {
3738 } ) ;
3839 it ( "should handle errors within ajv when validating" , ( ) => {
3940 const rule = new JsonSchemaFakerRule ( ) ;
40- const Call = {
41+ const call : Call = {
4142 title : 'test call' ,
4243 methodName : "foo" ,
4344 params : [ ] ,
@@ -47,13 +48,13 @@ describe("JsonSchemaFakerRule", () => {
4748 unevaluatedProperties : false ,
4849 } ,
4950 } ;
50- const result = rule . validateCall ( Call ) ;
51+ const result = rule . validateCall ( call ) ;
5152 expect ( result . valid ) . toBe ( false ) ;
5253 expect ( result . reason ) . toMatch ( 'unknown keyword: "unevaluatedProperties"' ) ;
5354 } ) ;
5455 it ( "should produce a readable error for reason" , ( ) => {
5556 const rule = new JsonSchemaFakerRule ( ) ;
56- const Call = {
57+ const call : Call = {
5758 title : 'test call' ,
5859 methodName : "foo" ,
5960 params : [ ] ,
@@ -63,9 +64,10 @@ describe("JsonSchemaFakerRule", () => {
6364 } ,
6465 result : "potato" ,
6566 } ;
66- const result = rule . validateCall ( Call ) ;
67+ const result = rule . validateCall ( call ) ;
6768 expect ( result . valid ) . toBe ( false ) ;
6869 expect ( result . reason ) . toContain ( 'expected:\n "potato"' ) ;
69- expect ( result . reason ) . toContain ( ' to match schema: \n{\n "type":"boolean"\n}' ) ;
70+ expect ( result . reason ) . toContain ( 'to match schema:' ) ;
71+ expect ( result . reason ) . toContain ( JSON . stringify ( call . resultSchema , null , 2 ) ) ;
7072 } ) ;
7173} ) ;
0 commit comments