|
| 1 | +jest.mock("danger", () => jest.fn()) |
| 2 | +import danger from 'danger' |
| 3 | +const dm = danger as any; |
| 4 | + |
| 5 | +import { dodChecked } from '../org/allPRs' |
| 6 | + |
| 7 | +beforeEach(() => { |
| 8 | + dm.warn = jest.fn().mockReturnValue(true); |
| 9 | + dm.fail = jest.fn().mockReturnValue(true); |
| 10 | + |
| 11 | + dm.danger = { |
| 12 | + github: { |
| 13 | + pr: { |
| 14 | + body: "", |
| 15 | + } |
| 16 | + }, |
| 17 | + } |
| 18 | +}) |
| 19 | + |
| 20 | +describe("Definition of Done checked", () => { |
| 21 | + it("does fail when Definition of Done checkbox is not in the body", async () => { |
| 22 | + var prBody = "**Steps to test this PR**:\n1.\n2.\n" |
| 23 | + prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape" |
| 24 | + dm.danger.github.pr.body = prBody |
| 25 | + |
| 26 | + await dodChecked() |
| 27 | + |
| 28 | + expect(dm.fail).toHaveBeenCalledWith("Please, make sure this PR satisfies our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f) and the relevant checkbox is checked.") |
| 29 | + }) |
| 30 | + |
| 31 | + it("does fail when Definition of Done checkbox is not checked", async () => { |
| 32 | + var prBody = "**Steps to test this PR**:\n1.\n2.\n" |
| 33 | + prBody += "**Definition of Done (Internal Only)**:\n* [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?\n" |
| 34 | + prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape" |
| 35 | + dm.danger.github.pr.body = prBody |
| 36 | + |
| 37 | + await dodChecked() |
| 38 | + |
| 39 | + expect(dm.fail).toHaveBeenCalledWith("Please, make sure this PR satisfies our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f) and the relevant checkbox is checked.") |
| 40 | + }) |
| 41 | + |
| 42 | + it("does not fail when Definition of Done checkbox is checked (Lower Case)", async () => { |
| 43 | + var prBody = "**Steps to test this PR**:\n1.\n2.\n" |
| 44 | + prBody += "**Definition of Done (Internal Only)**:\n* [x] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?\n" |
| 45 | + prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape" |
| 46 | + dm.danger.github.pr.body = prBody |
| 47 | + |
| 48 | + await dodChecked() |
| 49 | + |
| 50 | + expect(dm.fail).not.toHaveBeenCalled() |
| 51 | + }) |
| 52 | + |
| 53 | + it("does not fail when Definition of Done checkbox is checked (Upper Case)", async () => { |
| 54 | + var prBody = "**Steps to test this PR**:\n1.\n2.\n" |
| 55 | + prBody += "**Definition of Done (Internal Only)**:\n* [X] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?\n" |
| 56 | + prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape" |
| 57 | + dm.danger.github.pr.body = prBody |
| 58 | + |
| 59 | + await dodChecked() |
| 60 | + |
| 61 | + expect(dm.fail).not.toHaveBeenCalled() |
| 62 | + }) |
| 63 | +}) |
0 commit comments