humpty
Version:
Makes sure your changelogs mention your breaking changes
54 lines (52 loc) • 2.27 kB
JavaScript
import printUnmentionedChanges from "../src/printUnmentionedChanges";
import singlePropWithTypeChange from "./inputs/printUnmentionedChanges/singlePropWithTypeChange";
import multiplePropsChanged from "./inputs/printUnmentionedChanges/multiplePropsChanged";
import changesInDefaultAndNamedExports from "./inputs/printUnmentionedChanges/changesInDefaultAndNamedExports";
import namedExportRemoved from "./inputs/printUnmentionedChanges/namedExportRemoved";
import defaultExportRemoved from "./inputs/printUnmentionedChanges/defaultExportRemoved";
describe("printUnmentionedChanges()", () => {
describe("intro line", () => {
test("with a single change", () => {
expect(printUnmentionedChanges(singlePropWithTypeChange)).toContain(
"Found 1 breaking API change not mentioned"
);
});
test("with multiple changes", () => {
expect(printUnmentionedChanges(multiplePropsChanged)).toContain(
"Found 3 breaking API changes not mentioned"
);
});
});
describe("git commit refs", () => {
test("should be truncated to 6 characters if a sha ref", () => {
expect(printUnmentionedChanges(singlePropWithTypeChange)).toContain(
"git commits (aaaa11..ffff99)"
);
});
test("should not be changed if not a sha ref", () => {
expect(printUnmentionedChanges(multiplePropsChanged)).toContain(
"git commits (aaaa11..my-branch)"
);
});
});
describe("sections for default and named exports", () => {
test("should contain correct sections", () => {
const output = printUnmentionedChanges(changesInDefaultAndNamedExports);
expect(output).toContain("Found 2 breaking");
expect(output).toContain(`Default export
- Prop type changed: "age" was string, now number.
Dog
- Prop removed: "age".`);
});
});
test("when named export removed", () => {
const output = printUnmentionedChanges(namedExportRemoved);
expect(output).toContain(`Dog
- Export removed: Dog is no longer exported from the entry file.`);
});
test("when default export removed", () => {
const output = printUnmentionedChanges(defaultExportRemoved);
expect(output).toContain(`Default export
- Export removed: There is no longer a default export.`);
});
});