@@ -27,6 +27,7 @@ const mockSchema = {
2727 } ,
2828 {
2929 name : "bar" ,
30+ paramStructure : "by-name" ,
3031 params : [
3132 {
3233 name : "barParam" ,
@@ -49,6 +50,54 @@ const mockSchema = {
4950 type : "boolean" ,
5051 } ,
5152 } ,
53+ examples : [
54+ {
55+ name : "fooExample" ,
56+ summary : "foo example" ,
57+ description : "this is an example of foo" ,
58+ params : [
59+ {
60+ name : "barParam" ,
61+ value : "bar" ,
62+ } ,
63+ {
64+ name : "barParam2" ,
65+ value : "bar" ,
66+ }
67+ ] ,
68+ result : {
69+ name : "fooResult" ,
70+ schema : {
71+ type : "boolean" ,
72+ } ,
73+ } ,
74+ } ,
75+ ] ,
76+ } ,
77+ {
78+ name : "baz" ,
79+ params : [
80+ {
81+ name : "bazParam" ,
82+ required : true ,
83+ schema : {
84+ type : "string" ,
85+ enum : [ "baz" ] ,
86+ } ,
87+ } ,
88+ {
89+ name : "bazParam2" ,
90+ schema : {
91+ type : "string" ,
92+ } ,
93+ } ,
94+ ] ,
95+ result : {
96+ name : "bazResult" ,
97+ schema : {
98+ type : "boolean" ,
99+ } ,
100+ } ,
52101 examples : [
53102 {
54103 name : "fooExample" ,
@@ -109,6 +158,29 @@ describe("coverage", () => {
109158 } ) ;
110159 } ) ;
111160 } ) ;
161+ describe ( "coverage tests" , ( ) => {
162+ it ( "throws an error when there are no methods" , async ( ) => {
163+ const reporter = new class CustomReporter {
164+ onBegin ( ) { }
165+ onTestBegin ( ) { }
166+ onTestEnd ( ) { }
167+ onEnd ( ) { }
168+ } ;
169+ const spy = jest . spyOn ( reporter , "onTestBegin" ) ;
170+ const transport = ( ) => Promise . resolve ( { } ) ;
171+ const openrpcDocument = mockSchema ;
172+ const options = {
173+ reporter,
174+ transport,
175+ openrpcDocument,
176+ skip : [ 'foo' , 'bar' , 'baz' ] ,
177+ only : [ ] ,
178+ } ;
179+
180+ await coverage ( options ) ;
181+ expect ( spy ) . toHaveBeenCalledTimes ( 0 ) ;
182+ } ) ;
183+ } ) ;
112184 describe ( "transport" , ( ) => {
113185 it ( "can call the transport" , ( done ) => {
114186 const transport = ( ) => {
@@ -124,7 +196,7 @@ describe("coverage", () => {
124196 } ) ;
125197 } ) ;
126198 } ) ;
127- describe ( "reporter" , ( ) => {
199+ describe ( "reporter more tests " , ( ) => {
128200 // reporter integration tests
129201 it ( "onBegin is called" , async ( ) => {
130202 // this is a test that the reporter is called
@@ -162,7 +234,7 @@ describe("coverage", () => {
162234 } ;
163235
164236 await coverage ( options ) ;
165- expect ( spy ) . toHaveBeenCalledTimes ( 11 ) ;
237+ expect ( spy ) . toHaveBeenCalledTimes ( 12 ) ;
166238 } ) ;
167239 } ) ;
168240} ) ;
0 commit comments