-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxcodeprojObjectVersion.allPRs.test.ts
More file actions
97 lines (74 loc) · 2.81 KB
/
xcodeprojObjectVersion.allPRs.test.ts
File metadata and controls
97 lines (74 loc) · 2.81 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
jest.mock("danger", () => jest.fn())
import danger from 'danger'
const dm = danger as any;
import { xcodeprojObjectVersion_macOS } from '../org/allPRs'
beforeEach(() => {
dm.addedLines = ""
dm.fail = jest.fn().mockReturnValue(true);
dm.danger = {
git: {
diffForFile: async (_filename) => {
return { added: dm.addedLines }
},
modified_files: [
"macOS/DuckDuckGo-macOS.xcodeproj/project.pbxproj"
]
},
github: {
pr: {
additions: 200,
deletions: 10
},
thisPR: {
repo: "apple-browsers"
}
},
}
})
describe("Xcode project file configuration checks", () => {
it("does not fail with no changes to project file", async () => {
dm.danger.git.modified_files = []
await xcodeprojObjectVersion_macOS()
expect(dm.fail).not.toHaveBeenCalled()
})
it("does not fail with no diff in project file", async () => {
dm.danger.git.diffForFile = async (_filename) => {}
await xcodeprojObjectVersion_macOS()
expect(dm.fail).not.toHaveBeenCalled()
})
it("does not fail with no additions", async () => {
await xcodeprojObjectVersion_macOS()
expect(dm.fail).not.toHaveBeenCalled()
})
it("does not fail with added source file", async () => {
dm.addedLines = `
+ 372C27BE297AD5C200C758EB /* Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372C27BD297AD5C200C758EB /* Test.swift */; };
+ 372C27BD297AD5C200C758EB /* Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Test.swift; sourceTree = "<group>"; };
+ 372C27BD297AD5C200C758EB /* Test.swift */,
+ 372C27BE297AD5C200C758EB /* Test.swift in Sources */,
`
await xcodeprojObjectVersion_macOS()
expect(dm.fail).not.toHaveBeenCalled()
})
it("does not fail with objectVersion change to 60", async () => {
dm.addedLines = `
+ objectVersion = 60;
`
await xcodeprojObjectVersion_macOS()
expect(dm.fail).not.toHaveBeenCalled()
})
it("does not fail with objectVersion change to a number lower than 60", async () => {
dm.addedLines = `
+ objectVersion = 55;
`
await xcodeprojObjectVersion_macOS()
expect(dm.fail).not.toHaveBeenCalled()
})
it("fails with objectVersion change to a number greater than 60", async () => {
dm.addedLines = `
+ objectVersion = 70;
`
await xcodeprojObjectVersion_macOS()
expect(dm.fail).toHaveBeenCalledWith("macOS Xcode project file needs to keep objectVersion at 60 - you may have added a buildable folder reference to the project file. Please replace it with a file group.")
})
})