-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
84 lines (75 loc) · 2.31 KB
/
index.test.js
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
jest.mock('@expo/config-plugins', () => ({
withGradleProperties: (config, action) => {
const exportedConfig = {
modResults: config.android.gradleProperties.modResults
};
const result = action(exportedConfig);
return {
...config,
android: {
...config.android,
gradleProperties: result
}
};
}
}));
const withConfigPlugin = require('./index');
describe('Gradle Properties Plugin', () => {
test('should add properties when none exist', () => {
const mockConfig = {
modResults: []
};
const config = {
android: {
gradleProperties: mockConfig
}
};
const result = withConfigPlugin(config);
const properties = result.android.gradleProperties.modResults;
expect(properties).toContainEqual({
type: 'property',
key: 'android.enableJetifier',
value: true
});
expect(properties).toContainEqual({
type: 'property',
key: 'org.gradle.jvmargs',
value: '-Xmx4096m -XX:MaxMetaspaceSize=512m'
});
expect(properties.length).toBe(2);
});
test('should update existing properties', () => {
const mockConfig = {
modResults: [
{
type: 'property',
key: 'android.enableJetifier',
value: false
},
{
type: 'property',
key: 'org.gradle.jvmargs',
value: '-Xmx2048m'
}
]
};
const config = {
android: {
gradleProperties: mockConfig
}
};
const result = withConfigPlugin(config);
const properties = result.android.gradleProperties.modResults;
expect(properties).toContainEqual({
type: 'property',
key: 'android.enableJetifier',
value: true
});
expect(properties).toContainEqual({
type: 'property',
key: 'org.gradle.jvmargs',
value: '-Xmx4096m -XX:MaxMetaspaceSize=512m'
});
expect(properties.length).toBe(2);
});
});