|
| 1 | +jest.mock("danger", () => jest.fn()) |
| 2 | +import danger from 'danger' |
| 3 | +const dm = danger as any; |
| 4 | + |
| 5 | +import { remoteReleasableFeatureWarning } from '../org/allPRs' |
| 6 | + |
| 7 | +beforeEach(() => { |
| 8 | + dm.addedLines = "" |
| 9 | + dm.warn = jest.fn().mockReturnValue(true); |
| 10 | + |
| 11 | + dm.danger = { |
| 12 | + git: { |
| 13 | + diffForFile: async (_filename) => { |
| 14 | + return { added: dm.addedLines } |
| 15 | + }, |
| 16 | + modified_files: [ |
| 17 | + "ModifiedFile.swift" |
| 18 | + ], |
| 19 | + created_files: [ |
| 20 | + "CreatedFile.swift" |
| 21 | + ] |
| 22 | + } |
| 23 | + } |
| 24 | +}) |
| 25 | + |
| 26 | +describe("remoteReleasable(.feature warning", () => { |
| 27 | + it("does not warn with no changes to Swift files", async () => { |
| 28 | + dm.danger.git.modified_files = ["ModifiedFile.m"] |
| 29 | + dm.danger.git.created_files = [] |
| 30 | + |
| 31 | + await remoteReleasableFeatureWarning() |
| 32 | + expect(dm.warn).not.toHaveBeenCalled() |
| 33 | + }) |
| 34 | + |
| 35 | + it("does not warn with no diff in Swift files", async () => { |
| 36 | + dm.danger.git.diffForFile = async (_filename) => {} |
| 37 | + |
| 38 | + await remoteReleasableFeatureWarning() |
| 39 | + expect(dm.warn).not.toHaveBeenCalled() |
| 40 | + }) |
| 41 | + |
| 42 | + it("does not warn with deletions", async () => { |
| 43 | + dm.addedLines = ` |
| 44 | +- .remoteReleasable(.feature("example")) |
| 45 | + ` |
| 46 | + |
| 47 | + await remoteReleasableFeatureWarning() |
| 48 | + expect(dm.warn).not.toHaveBeenCalled() |
| 49 | + }) |
| 50 | + |
| 51 | + it("warns with remoteReleasable(.feature additions", async () => { |
| 52 | + dm.addedLines = ` |
| 53 | ++ .remoteReleasable(.feature("example")) |
| 54 | + ` |
| 55 | + |
| 56 | + await remoteReleasableFeatureWarning() |
| 57 | + expect(dm.warn).toHaveBeenCalledWith("⚠️ Parent feature flags do not support rollouts - if you wish to use a rollout for your feature, please use a subfeature flag.") |
| 58 | + }) |
| 59 | +}) |
0 commit comments