Skip to content

Commit c576d7f

Browse files
committed
chore(tests): Added ios pbxproj tests and new tests for direct semver set flag
1 parent 608c154 commit c576d7f

6 files changed

Lines changed: 176 additions & 0 deletions

File tree

tests/__snapshots__/android.test.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`direct set semver string 1`] = `
4+
"android {
5+
defaultConfig {
6+
versionCode 2
7+
versionName \\"1.1.2\\"
8+
}
9+
}
10+
"
11+
`;
12+
13+
exports[`direct set semver string 2`] = `
14+
Object {
15+
"version": "1.1.2",
16+
}
17+
`;
18+
319
exports[`preserve quotes style 1`] = `
420
"android {
521
defaultConfig {
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`direct set semver string 1`] = `
4+
"// !$*UTF8*$!
5+
{
6+
objects = {
7+
/* Begin XCBuildConfiguration section */
8+
13B07F941A680F5B01A75B9A /* Debug */ = {
9+
isa = XCBuildConfiguration;
10+
buildSettings = {
11+
MARKETING_VERSION = 1.1.2;
12+
CURRENT_PROJECT_VERSION = 32;
13+
};
14+
name = Debug;
15+
};
16+
13B07F951A680F5B01A75B9A /* Release */ = {
17+
isa = XCBuildConfiguration;
18+
buildSettings = {
19+
MARKETING_VERSION = 1.1.2;
20+
CURRENT_PROJECT_VERSION = 32;
21+
};
22+
name = Release;
23+
};
24+
/* End XCBuildConfiguration section */
25+
};
26+
}
27+
"
28+
`;
29+
30+
exports[`direct set semver string 2`] = `
31+
Object {
32+
"version": "1.1.2",
33+
}
34+
`;
35+
36+
exports[`skip semVer when asked 1`] = `
37+
"// !$*UTF8*$!
38+
{
39+
objects = {
40+
/* Begin XCBuildConfiguration section */
41+
13B07F941A680F5B01A75B9A /* Debug */ = {
42+
isa = XCBuildConfiguration;
43+
buildSettings = {
44+
MARKETING_VERSION = 1.0.0;
45+
CURRENT_PROJECT_VERSION = 32;
46+
};
47+
name = Debug;
48+
};
49+
13B07F951A680F5B01A75B9A /* Release */ = {
50+
isa = XCBuildConfiguration;
51+
buildSettings = {
52+
MARKETING_VERSION = 1.0.0;
53+
CURRENT_PROJECT_VERSION = 32;
54+
};
55+
name = Release;
56+
};
57+
/* End XCBuildConfiguration section */
58+
};
59+
}
60+
"
61+
`;
62+
63+
exports[`successfully bump version 1`] = `
64+
"// !$*UTF8*$!
65+
{
66+
objects = {
67+
/* Begin XCBuildConfiguration section */
68+
13B07F941A680F5B01A75B9A /* Debug */ = {
69+
isa = XCBuildConfiguration;
70+
buildSettings = {
71+
MARKETING_VERSION = 1.1.0;
72+
CURRENT_PROJECT_VERSION = 32;
73+
};
74+
name = Debug;
75+
};
76+
13B07F951A680F5B01A75B9A /* Release */ = {
77+
isa = XCBuildConfiguration;
78+
buildSettings = {
79+
MARKETING_VERSION = 1.1.0;
80+
CURRENT_PROJECT_VERSION = 32;
81+
};
82+
name = Release;
83+
};
84+
/* End XCBuildConfiguration section */
85+
};
86+
}
87+
"
88+
`;

tests/android.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ const path = require('path')
22
const { ProjectFilesManager } = require('../lib/index')
33

44
const makeDefaultManager = ({
5+
version,
56
type = 'minor',
67
skipSemVerFor = 'ios',
78
skipCodeFor = 'ios',
89
gradleFileName = 'double.gradle'
910
} = {}) => new ProjectFilesManager({
1011
type,
12+
version,
1113
skipSemVerFor,
1214
skipCodeFor,
1315
root: path.join(__dirname, 'android'),
@@ -32,3 +34,10 @@ test('preserve quotes style', () => {
3234

3335
expect(manager.buildGradle.content).toMatchSnapshot()
3436
})
37+
38+
test('direct set semver string', () => {
39+
const manager = makeDefaultManager({ version: '1.1.2' }).dryRun()
40+
41+
expect(manager.buildGradle.content).toMatchSnapshot()
42+
expect(manager.packageJSON.content).toMatchSnapshot()
43+
})

tests/ios.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const path = require('path')
2+
const { ProjectFilesManager } = require('../lib/index')
3+
4+
const makeDefaultManager = ({
5+
version,
6+
type = 'minor',
7+
skipSemVerFor = 'android',
8+
skipCodeFor = 'android',
9+
pbxFileName = 'project.pbxproj'
10+
} = {}) => new ProjectFilesManager({
11+
type,
12+
version,
13+
skipSemVerFor,
14+
skipCodeFor,
15+
root: path.join(__dirname, 'ios'),
16+
pbxprojPath: path.join(__dirname, 'ios', pbxFileName)
17+
})
18+
19+
test('successfully bump version', () => {
20+
const manager = makeDefaultManager().dryRun()
21+
22+
expect(manager.pbx.content).toMatchSnapshot()
23+
})
24+
25+
26+
test('skip semVer when asked', () => {
27+
const manager = makeDefaultManager({ skipSemVerFor: 'all' }).dryRun()
28+
29+
expect(manager.pbx.content).toMatchSnapshot()
30+
})
31+
32+
test('direct set semver string', () => {
33+
const manager = makeDefaultManager({ version: '1.1.2' }).dryRun()
34+
35+
expect(manager.pbx.content).toMatchSnapshot()
36+
expect(manager.packageJSON.content).toMatchSnapshot()
37+
})

tests/ios/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "1.0.0"
3+
}

tests/ios/project.pbxproj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// !$*UTF8*$!
2+
{
3+
objects = {
4+
/* Begin XCBuildConfiguration section */
5+
13B07F941A680F5B01A75B9A /* Debug */ = {
6+
isa = XCBuildConfiguration;
7+
buildSettings = {
8+
MARKETING_VERSION = 1.0.0;
9+
CURRENT_PROJECT_VERSION = 31;
10+
};
11+
name = Debug;
12+
};
13+
13B07F951A680F5B01A75B9A /* Release */ = {
14+
isa = XCBuildConfiguration;
15+
buildSettings = {
16+
MARKETING_VERSION = 1.0.0;
17+
CURRENT_PROJECT_VERSION = 31;
18+
};
19+
name = Release;
20+
};
21+
/* End XCBuildConfiguration section */
22+
};
23+
}

0 commit comments

Comments
 (0)