Skip to content

Commit 2b10ff0

Browse files
author
Ben McKernan
committed
test: Add tests for references-empty-enum rule
1 parent 17ab0ec commit 2b10ff0

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

references-empty-enum.test.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const check = require("./references-empty-enum");
2+
3+
it("succeeds when the commit has no type", () => {
4+
const [actual] = check({ type: "" });
5+
expect(actual).toBe(true);
6+
});
7+
8+
it("succeeds when the type enum is empty", () => {
9+
const [actual] = check({ type: "fix" }, "always", []);
10+
expect(actual).toBe(true);
11+
});
12+
13+
describe("when references is empty", () => {
14+
const references = [];
15+
16+
test("a on 'always [a]' succeeds", () => {
17+
const [actual] = check({ references, type: "a" }, "always", ["a"]);
18+
expect(actual).toBe(true);
19+
});
20+
21+
test("b on 'always [a]' succeeds", () => {
22+
const [actual] = check({ references, type: "b" }, "always", ["a"]);
23+
expect(actual).toBe(true);
24+
});
25+
26+
test("a on 'never [a]' fails", () => {
27+
const [actual] = check({ references, type: "a" }, "never", ["a"]);
28+
expect(actual).toBe(false);
29+
});
30+
31+
test("b on 'never [a]' succeeds", () => {
32+
const [actual] = check({ references, type: "b" }, "never", ["a"]);
33+
expect(actual).toBe(true);
34+
});
35+
});
36+
37+
describe("when references is not empty", () => {
38+
const references = ["CMS-123"];
39+
40+
test("a on 'always [a]' fails", () => {
41+
const [actual] = check({ references, type: "a" }, "always", ["a"]);
42+
expect(actual).toBe(false);
43+
});
44+
45+
test("b on 'always [a]' succeeds", () => {
46+
const [actual] = check({ references, type: "b" }, "always", ["a"]);
47+
expect(actual).toBe(true);
48+
});
49+
50+
test("a on 'never [a]' succeeds", () => {
51+
const [actual] = check({ references, type: "a" }, "never", ["a"]);
52+
expect(actual).toBe(true);
53+
});
54+
55+
test("b on 'never [a]' succeeds", () => {
56+
const [actual] = check({ references, type: "b" }, "never", ["a"]);
57+
expect(actual).toBe(true);
58+
});
59+
});

0 commit comments

Comments
 (0)