-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathremoteReleasableFeatureWarning.allPRs.test.ts
More file actions
59 lines (48 loc) · 1.72 KB
/
remoteReleasableFeatureWarning.allPRs.test.ts
File metadata and controls
59 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
jest.mock("danger", () => jest.fn())
import danger from 'danger'
const dm = danger as any;
import { remoteReleasableFeatureWarning } from '../org/allPRs'
beforeEach(() => {
dm.addedLines = ""
dm.warn = jest.fn().mockReturnValue(true);
dm.danger = {
git: {
diffForFile: async (_filename) => {
return { added: dm.addedLines }
},
modified_files: [
"ModifiedFile.swift"
],
created_files: [
"CreatedFile.swift"
]
}
}
})
describe("remoteReleasable(.feature warning", () => {
it("does not warn with no changes to Swift files", async () => {
dm.danger.git.modified_files = ["ModifiedFile.m"]
dm.danger.git.created_files = []
await remoteReleasableFeatureWarning()
expect(dm.warn).not.toHaveBeenCalled()
})
it("does not warn with no diff in Swift files", async () => {
dm.danger.git.diffForFile = async (_filename) => {}
await remoteReleasableFeatureWarning()
expect(dm.warn).not.toHaveBeenCalled()
})
it("does not warn with deletions", async () => {
dm.addedLines = `
- .remoteReleasable(.feature("example"))
`
await remoteReleasableFeatureWarning()
expect(dm.warn).not.toHaveBeenCalled()
})
it("warns with remoteReleasable(.feature additions", async () => {
dm.addedLines = `
+ .remoteReleasable(.feature("example"))
`
await remoteReleasableFeatureWarning()
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.")
})
})