Skip to content

Commit 7e316b8

Browse files
committed
make sure to check funcs in context calls too
- `get-options-overrides`'s coverage func % decreased bc funcs passed to `context.debug` weren't being called - took me a bit to notice too since we have no coverage checks - and then another bit to realize _why_ it decreased
1 parent 75e04a6 commit 7e316b8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

__tests__/fixtures/context.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ import { PluginContext } from "rollup";
33

44
import { IContext } from "../../src/context";
55

6+
// if given a function, make sure to call it (for code coverage etc)
7+
function returnText (message: string | (() => string)) {
8+
if (typeof message === "string")
9+
return message;
10+
11+
return message();
12+
}
13+
614
export function makeContext(): PluginContext & IContext {
715
return {
8-
error: jest.fn(),
9-
warn: jest.fn(),
10-
info: jest.fn(),
11-
debug: jest.fn(),
16+
error: jest.fn(returnText),
17+
warn: jest.fn(returnText),
18+
info: jest.fn(returnText),
19+
debug: jest.fn(returnText),
1220
} as unknown as PluginContext & IContext;
1321
};

0 commit comments

Comments
 (0)