clean-code-metrics
Version:
metrics for clean code
43 lines (36 loc) • 1.26 kB
text/typescript
import summary from "../../cli/summary";
import chalk from "chalk";
chalk.level = 0; // disable colors for compatibility e.g. pipeline
const configPath = "./src/TEST/test.config.json";
const configPath2 = "./src/TEST/test2.config.json";
const configPath3 = "./src/TEST/test3.config.json";
function prepareMock() {
const info = jest.spyOn(console, "info").mockImplementation(undefined);
beforeEach(() => info.mockReset());
return info;
}
describe("test summmary", () => {
const info = prepareMock();
it("not verbose", async () => {
await summary(undefined, false, configPath);
expect(info.mock.calls[0][0]).toMatchSnapshot();
});
it("verbose", async () => {
await summary(undefined, true, configPath);
expect(info.mock.calls[0][0]).toMatchSnapshot();
});
});
describe("test summary ignoreCase:true", () => {
const info = prepareMock();
it("not verbose", async () => {
await summary(undefined, false, configPath2);
expect(info.mock.calls[0][0]).toMatchSnapshot();
});
});
describe("test summary with taskFilter and custom task", () => {
const info = prepareMock();
it("match snapshot", async () => {
await summary(["TODO", "FIXME", "BUG", "CUSTOM"], false, configPath3);
expect(info.mock.calls[0][0]).toMatchSnapshot();
});
});