|
| 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