breautek commented on code in PR #1274:
URL: https://github.com/apache/cordova-ios/pull/1274#discussion_r1040234428


##########
tests/spec/unit/prepare.spec.js:
##########
@@ -649,6 +649,60 @@ describe('prepare', () => {
             });
         });
 
+        it('should support Mac apps by default', () => {
+            cfg2.name = () => 'SampleApp'; // new config does *not* have a 
name change
+            writeFileSyncSpy.and.callThrough();
+            return updateProject(cfg2, p.locations).then(() => {
+                const xcode = require('xcode');
+                const proj = new xcode.project(p.locations.pbxproj); /* eslint 
new-cap : 0 */

Review Comment:
   `xcode.project` shouldn't be called with `new`. Additionally, the test file 
imports it as
   
   ```javascript
   const xcode = require('xcode');
   const XcodeProject = xcode.project;
   ```
   
   So you can use `XcodeProject` for consistency.
   
   ```suggestion
                   const proj = XcodeProject(p.locations.pbxproj);
   ```
   
   I think this will fix:
   
   ```
   1) prepare updateProject method should support Mac apps by default
     Message:
       TypeError: target is not a constructor
     Stack:
       TypeError: target is not a constructor
           at <Jasmine>
           at 
/Users/runner/work/cordova-ios/cordova-ios/tests/spec/unit/prepare.spec.js:657:30
   ```



##########
tests/spec/unit/prepare.spec.js:
##########
@@ -649,6 +649,60 @@ describe('prepare', () => {
             });
         });
 
+        it('should support Mac apps by default', () => {
+            cfg2.name = () => 'SampleApp'; // new config does *not* have a 
name change
+            writeFileSyncSpy.and.callThrough();
+            return updateProject(cfg2, p.locations).then(() => {
+                const xcode = require('xcode');
+                const proj = new xcode.project(p.locations.pbxproj); /* eslint 
new-cap : 0 */
+                proj.parseSync();
+                const supportedPlatforms = 
proj.getBuildProperty('SUPPORTED_PLATFORMS');
+                expect(supportedPlatforms).toBeUndefined();
+                const supportsMacCatalyst = 
proj.getBuildProperty('SUPPORTS_MACCATALYST');
+                expect(supportsMacCatalyst).toBeUndefined();
+                const supportsMacIPhoneIPad = 
proj.getBuildProperty('SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD');
+                expect(supportsMacIPhoneIPad).toBeUndefined();
+            });
+        });
+
+        it('should support Mac apps if SupportMac preference is set to true', 
() => {
+            cfg3.name = () => 'SampleApp'; // new config does *not* have a 
name change
+            const pref = cfg3.doc.findall('platform[@name=\'ios\']/preference')
+                .filter(elem => elem.attrib.name.toLowerCase() === 
'supportmac')[0];
+            pref.attrib.value = 'true';
+            writeFileSyncSpy.and.callThrough();
+            return updateProject(cfg3, p.locations).then(() => {
+                const xcode = require('xcode');
+                const proj = new xcode.project(p.locations.pbxproj); /* eslint 
new-cap : 0 */

Review Comment:
   See above
   
   ```suggestion
                   const proj = XcodeProject(p.locations.pbxproj);
   ```



##########
tests/spec/unit/prepare.spec.js:
##########
@@ -649,6 +649,60 @@ describe('prepare', () => {
             });
         });
 
+        it('should support Mac apps by default', () => {
+            cfg2.name = () => 'SampleApp'; // new config does *not* have a 
name change
+            writeFileSyncSpy.and.callThrough();
+            return updateProject(cfg2, p.locations).then(() => {
+                const xcode = require('xcode');
+                const proj = new xcode.project(p.locations.pbxproj); /* eslint 
new-cap : 0 */
+                proj.parseSync();
+                const supportedPlatforms = 
proj.getBuildProperty('SUPPORTED_PLATFORMS');
+                expect(supportedPlatforms).toBeUndefined();
+                const supportsMacCatalyst = 
proj.getBuildProperty('SUPPORTS_MACCATALYST');
+                expect(supportsMacCatalyst).toBeUndefined();
+                const supportsMacIPhoneIPad = 
proj.getBuildProperty('SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD');
+                expect(supportsMacIPhoneIPad).toBeUndefined();
+            });
+        });
+
+        it('should support Mac apps if SupportMac preference is set to true', 
() => {
+            cfg3.name = () => 'SampleApp'; // new config does *not* have a 
name change
+            const pref = cfg3.doc.findall('platform[@name=\'ios\']/preference')
+                .filter(elem => elem.attrib.name.toLowerCase() === 
'supportmac')[0];
+            pref.attrib.value = 'true';
+            writeFileSyncSpy.and.callThrough();
+            return updateProject(cfg3, p.locations).then(() => {
+                const xcode = require('xcode');
+                const proj = new xcode.project(p.locations.pbxproj); /* eslint 
new-cap : 0 */
+                proj.parseSync();
+                const supportedPlatforms = 
proj.getBuildProperty('SUPPORTED_PLATFORMS');
+                expect(supportedPlatforms).toBeUndefined();
+                const supportsMacCatalyst = 
proj.getBuildProperty('SUPPORTS_MACCATALYST');
+                expect(supportsMacCatalyst).toBeUndefined();
+                const supportsMacIPhoneIPad = 
proj.getBuildProperty('SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD');
+                expect(supportsMacIPhoneIPad).toBeUndefined();
+            });
+        });
+
+        it('should not support Mac apps if SupportMac preference is set to 
false', () => {
+            cfg3.name = () => 'SampleApp'; // new config does *not* have a 
name change
+            const pref = cfg3.doc.findall('platform[@name=\'ios\']/preference')
+                .filter(elem => elem.attrib.name.toLowerCase() === 
'supportmac')[0];
+            pref.attrib.value = 'false';
+            writeFileSyncSpy.and.callThrough();
+            return updateProject(cfg3, p.locations).then(() => {
+                const xcode = require('xcode');
+                const proj = new xcode.project(p.locations.pbxproj); /* eslint 
new-cap : 0 */

Review Comment:
   See above
   
   ```suggestion
                   const proj = XcodeProject(p.locations.pbxproj);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to