@@ -27,6 +27,7 @@ const mockSchema = {
27
27
} ,
28
28
{
29
29
name : "bar" ,
30
+ paramStructure : "by-name" ,
30
31
params : [
31
32
{
32
33
name : "barParam" ,
@@ -49,6 +50,54 @@ const mockSchema = {
49
50
type : "boolean" ,
50
51
} ,
51
52
} ,
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
+ } ,
52
101
examples : [
53
102
{
54
103
name : "fooExample" ,
@@ -109,6 +158,29 @@ describe("coverage", () => {
109
158
} ) ;
110
159
} ) ;
111
160
} ) ;
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
+ } ) ;
112
184
describe ( "transport" , ( ) => {
113
185
it ( "can call the transport" , ( done ) => {
114
186
const transport = ( ) => {
@@ -124,7 +196,7 @@ describe("coverage", () => {
124
196
} ) ;
125
197
} ) ;
126
198
} ) ;
127
- describe ( "reporter" , ( ) => {
199
+ describe ( "reporter more tests " , ( ) => {
128
200
// reporter integration tests
129
201
it ( "onBegin is called" , async ( ) => {
130
202
// this is a test that the reporter is called
@@ -162,7 +234,7 @@ describe("coverage", () => {
162
234
} ;
163
235
164
236
await coverage ( options ) ;
165
- expect ( spy ) . toHaveBeenCalledTimes ( 11 ) ;
237
+ expect ( spy ) . toHaveBeenCalledTimes ( 12 ) ;
166
238
} ) ;
167
239
} ) ;
168
240
} ) ;
0 commit comments