Skip to content

Commit

Permalink
make sure to check funcs in context calls too
Browse files Browse the repository at this point in the history
- `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
  • Loading branch information
agilgur5 committed Aug 24, 2022
1 parent 75e04a6 commit 7e316b8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions __tests__/fixtures/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ import { PluginContext } from "rollup";

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

// if given a function, make sure to call it (for code coverage etc)
function returnText (message: string | (() => string)) {
if (typeof message === "string")
return message;

return message();
}

export function makeContext(): PluginContext & IContext {
return {
error: jest.fn(),
warn: jest.fn(),
info: jest.fn(),
debug: jest.fn(),
error: jest.fn(returnText),
warn: jest.fn(returnText),
info: jest.fn(returnText),
debug: jest.fn(returnText),
} as unknown as PluginContext & IContext;
};

0 comments on commit 7e316b8

Please sign in to comment.