Skip to content

Commit 8bf16be

Browse files
committed
fix: improve coverage dramatically
1 parent 29dae6e commit 8bf16be

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/coverage.test.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ const mockSchema = {
106106
params: [],
107107
result: {
108108
name: "fooResult",
109-
schema: {
110-
type: "boolean",
111-
},
109+
value: true,
112110
},
113111
},
114112
],
@@ -177,8 +175,28 @@ describe("coverage", () => {
177175
only: [],
178176
};
179177

180-
await coverage(options);
181-
expect(spy).toHaveBeenCalledTimes(0);
178+
await expect(coverage(options)).rejects.toThrow('No methods to test');
179+
});
180+
it("can get to expectedResult checking with no servers", async () => {
181+
const reporter = new class CustomReporter {
182+
onBegin() {}
183+
onTestBegin() {}
184+
onTestEnd() {}
185+
onEnd() {}
186+
};
187+
const spy = jest.spyOn(reporter, "onTestBegin");
188+
const transport = () => Promise.resolve({});
189+
const openrpcDocument = {...mockSchema};
190+
openrpcDocument.servers = undefined;
191+
const options = {
192+
reporter,
193+
transport,
194+
openrpcDocument,
195+
skip: [],
196+
only: ['baz'],
197+
};
198+
199+
await expect(coverage(options)).resolves.toBeUndefined();
182200
});
183201
});
184202
describe("transport", () => {

src/coverage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export default async (options: IOptions) => {
6868
servers.forEach(({ url }) => {
6969
filteredMethods.forEach((method) => {
7070
if (method.examples === undefined || method.examples.length === 0) {
71-
console.log("method : ", method);
7271
for (let i = 0; i < 10; i++) {
7372
const p = getFakeParams(method.params);
7473
// handle object or array case
@@ -93,7 +92,6 @@ export default async (options: IOptions) => {
9392
method.paramStructure === "by-name"
9493
? paramsToObj(p, method.params as ContentDescriptorObject[])
9594
: p;
96-
console.log("params : ", params);
9795
exampleCalls.push({
9896
title: method.name + " > example params and expect result to match: " + ex.name,
9997
methodName: method.name,

0 commit comments

Comments
 (0)