Skip to content

Commit 6b74cbe

Browse files
author
Yosif Yosifov
committed
Add merge from App_Resources and Plugin integration test
1 parent dc508e6 commit 6b74cbe

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/ios-entitlements-service.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ describe("IOSEntitlements Service Tests", () => {
8080
<string>production</string>
8181
</dict>
8282
</plist>`;
83+
const namedAppResourcesEntitlementsContent = `<?xml version="1.0" encoding="UTF-8"?>
84+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
85+
<plist version="1.0">
86+
<dict>
87+
<key>nameKey</key>
88+
<string>appResources</string>
89+
</dict>
90+
</plist>`;
91+
const mergedEntitlementsContent = `<?xml version="1.0" encoding="UTF-8"?>
92+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
93+
<plist version="1.0">
94+
<dict>
95+
<key>aps-environment</key>
96+
<string>production</string>
97+
<key>nameKey</key>
98+
<string>appResources</string>
99+
</dict>
100+
</plist>`;
83101

84102
function assertContent(actual: string, expected: string) {
85103
let strip = (x: string) => {
@@ -127,5 +145,29 @@ describe("IOSEntitlements Service Tests", () => {
127145
let actual = fs.readText(destinationFilePath);
128146
assertContent(actual, defaultPluginEntitlementsContent);
129147
});
148+
149+
it("Merge uses App_Resources and Plugins and merges all keys", async () => {
150+
// setup app resoruces
151+
let appResourcesEntitlement = (<any>iOSEntitlementsService).getDefaultAppEntitlementsPath(projectData);
152+
fs.writeFile(appResourcesEntitlement, namedAppResourcesEntitlementsContent);
153+
154+
// setup plugin entitlements
155+
let pluginsService = injector.resolve("pluginsService");
156+
let testPluginFolderPath = temp.mkdirSync("testPlugin");
157+
pluginsService.getAllInstalledPlugins = async() => [{
158+
pluginPlatformsFolderPath: (platform: string) => {
159+
return testPluginFolderPath;
160+
}
161+
}];
162+
let pluginAppEntitlementsPath = path.join(testPluginFolderPath, IOSEntitlementsService.DefaultEntitlementsName);
163+
fs.writeFile(pluginAppEntitlementsPath, defaultPluginEntitlementsContent);
164+
165+
// act
166+
await iOSEntitlementsService.merge(projectData);
167+
168+
// assert
169+
let actual = fs.readText(destinationFilePath);
170+
assertContent(actual, mergedEntitlementsContent);
171+
});
130172
});
131173
});

0 commit comments

Comments
 (0)