github-advanced-security[bot] commented on code in PR #150:
URL:
https://github.com/apache/cordova-node-xcode/pull/150#discussion_r3031472173
##########
test/pbxTargetByName.js:
##########
@@ -16,8 +16,10 @@
specific language governing permissions and limitations
under the License.
*/
+const { describe, it, beforeEach, equals } = require('node:test');
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable equals.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/191)
##########
test/addRemovePbxGroup.js:
##########
@@ -26,154 +29,146 @@
return JSON.parse(fullProjectStr);
}
-exports.setUp = function (callback) {
- proj.hash = cleanHash();
- callback();
-}
+describe('addRemovePbxGroup', () => {
+ beforeEach(() => {
+ proj.hash = cleanHash();
+ });
-exports.addRemovePbxGroup = {
- 'should return a pbxGroup': function (test) {
+ it('should return a pbxGroup', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'Application', '"<group>"');
+ assert.ok(typeof pbxGroup === 'object');
+ });
- test.ok(typeof pbxGroup === 'object');
- test.done()
- },
- 'should set a uuid on the pbxGroup': function (test) {
+ it('should set a uuid on the pbxGroup', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'Application', '"<group>"');
+ assert.ok(pbxGroup.uuid);
+ });
- test.ok(pbxGroup.uuid);
- test.done()
- },
- 'should add all files to pbxGroup': function (test) {
+ it('should add all files to pbxGroup', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'Application', '"<group>"');
for (var index = 0; index < pbxGroup.pbxGroup.children.length;
index++) {
var file = pbxGroup.pbxGroup.children[index];
- test.ok(file.value);
+ assert.ok(file.value);
}
+ });
- test.done()
- },
- 'should add the PBXGroup object correctly': function (test) {
+ it('should add the PBXGroup object correctly', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'"<group>"');
- pbxGroupInPbx = proj.pbxGroupByName('MyGroup');
-
- test.equal(pbxGroupInPbx.children, pbxGroup.pbxGroup.children);
- test.equal(pbxGroupInPbx.isa, 'PBXGroup');
- test.equal(pbxGroupInPbx.path, 'Application');
- test.equal(pbxGroupInPbx.sourceTree, '"<group>"');
- test.done();
- },
- 'should add <group> sourceTree if no other specified': function (test) {
+ pbxGroupInPbx = proj.pbxGroupByName('MyGroup');
Review Comment:
## CodeQL / Missing variable declaration
Variable pbxGroupInPbx is used like a local variable, but is missing a
declaration.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/181)
##########
test/variantGroup.js:
##########
@@ -74,123 +77,115 @@
return found;
}
-exports.setUp = function(callback) {
- project = new pbx('test/parser/projects/variantgroup.pbxproj');
- projectHash = project.parseSync();
- callback();
-}
-
-exports.getVariantGroupByKey = {
- 'should return PBXVariantGroup for Localizable.strings': function(test) {
- var groupKey = project.findPBXVariantGroupKey({name:
'Localizable.strings'});
- var group = project.getPBXVariantGroupByKey(groupKey);
- test.ok(group.name === 'Localizable.strings');
- test.done();
- }
-}
-
-exports.createVariantGroup = {
- 'should create a new Test Variant Group': function(test) {
- delete project.getPBXObject('PBXVariantGroup');
-
- var found = false;
- var groups = project.getPBXObject('PBXVariantGroup');
-
- var found = findByName(groups, 'Test');
- test.ok(found === false);
-
- var group = project.findPBXVariantGroupKey({name:'Test'});
- test.ok(group === undefined);
-
- project.pbxCreateVariantGroup('Test');
-
- groups = project.getPBXObject('PBXVariantGroup');
- found = findByName(groups, 'Test');
- test.ok(found === true);
-
- group = project.findPBXVariantGroupKey({name:'Test'});
- test.ok(typeof group === 'string');
- test.done();
- }
-}
-
-exports.findVariantGroupKey = {
- 'should return a valid group key':function(test) {
- var keyByName = project.findPBXVariantGroupKey({ name:
'Localizable.strings'});
- var nonExistingKey = project.findPBXVariantGroupKey({ name: 'Foo'});
-
- test.ok(keyByName === '07E3BDBC1DF1DEA500E49912');
- test.ok(nonExistingKey === undefined);
-
- test.done();
- }
-}
-exports.createLocalisationVariantGroup = {
- 'should create a new localisation variationgroup then add group to
Resources group': function(test) {
- delete project.getPBXObject('PBXVariantGroup');
-
- var localizationVariantGp =
project.addLocalizationVariantGroup('InfoPlist.strings');
-
- var resourceGroupKey = project.findPBXGroupKey({name: 'Resources'});
- var resourceGroup = project.getPBXGroupByKey(resourceGroupKey);
- var foundInResourcesGroup = findChildInGroup(resourceGroup,
localizationVariantGp.fileRef );
- test.ok(foundInResourcesGroup);
-
- var foundInResourcesBuildPhase = false;
- var sources = project.pbxResourcesBuildPhaseObj();
- for (var i = 0, j = sources.files.length; i < j; i++) {
- var file = sources.files[i];
- if (file.value === localizationVariantGp.uuid) {
- foundInResourcesBuildPhase = true;
+describe('variantGroup', () => {
+ beforeEach(() => {
+ project = new pbx('test/parser/projects/variantgroup.pbxproj');
+ projectHash = project.parseSync();
+ });
+
+ describe('getVariantGroupByKey', () => {
+ it('should return PBXVariantGroup for Localizable.strings', () => {
+ var groupKey = project.findPBXVariantGroupKey({name:
'Localizable.strings'});
+ var group = project.getPBXVariantGroupByKey(groupKey);
+ assert.ok(group.name === 'Localizable.strings');
+ });
+ });
+
+ describe('createVariantGroup', () => {
+ it('should create a new Test Variant Group', () => {
+ delete project.getPBXObject('PBXVariantGroup');
Review Comment:
## CodeQL / Deleting non-property
Only properties should be deleted.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/176)
##########
test/addSourceFile.js:
##########
@@ -27,150 +29,135 @@
return JSON.parse(fullProjectStr);
}
-exports.setUp = function (callback) {
+describe('addSourceFile', () => {
+ beforeEach(() => {
proj.hash = cleanHash();
- callback();
-}
-
-exports.addSourceFile = {
- 'should return a pbxFile': function (test) {
- var newFile = proj.addSourceFile('file.m');
-
- test.equal(newFile.constructor, pbxFile);
- test.done()
- },
- 'should set a uuid on the pbxFile': function (test) {
- var newFile = proj.addSourceFile('file.m');
-
- test.ok(newFile.uuid);
- test.done()
- },
- 'should set a fileRef on the pbxFile': function (test) {
- var newFile = proj.addSourceFile('file.m');
-
- test.ok(newFile.fileRef);
- test.done()
- },
- 'should populate the PBXBuildFile section with 2 fields': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- buildFileSection = proj.pbxBuildFileSection(),
- bfsLength = Object.keys(buildFileSection).length;
-
- test.equal(60, bfsLength);
- test.ok(buildFileSection[newFile.uuid]);
- test.ok(buildFileSection[newFile.uuid + '_comment']);
-
- test.done();
- },
- 'should add the PBXBuildFile comment correctly': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- commentKey = newFile.uuid + '_comment',
- buildFileSection = proj.pbxBuildFileSection();
-
- test.equal(buildFileSection[commentKey], 'file.m in Sources');
- test.done();
- },
- 'should add the PBXBuildFile object correctly': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- buildFileSection = proj.pbxBuildFileSection(),
- buildFileEntry = buildFileSection[newFile.uuid];
-
- test.equal(buildFileEntry.isa, 'PBXBuildFile');
- test.equal(buildFileEntry.fileRef, newFile.fileRef);
- test.equal(buildFileEntry.fileRef_comment, 'file.m');
-
- test.done();
- },
- 'should populate the PBXFileReference section with 2 fields': function
(test) {
- var newFile = proj.addSourceFile('file.m'),
- fileRefSection = proj.pbxFileReferenceSection(),
- frsLength = Object.keys(fileRefSection).length;
-
- test.equal(68, frsLength);
- test.ok(fileRefSection[newFile.fileRef]);
- test.ok(fileRefSection[newFile.fileRef + '_comment']);
-
- test.done();
- },
- 'should populate the PBXFileReference comment correctly': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- fileRefSection = proj.pbxFileReferenceSection(),
- commentKey = newFile.fileRef + '_comment';
-
- test.equal(fileRefSection[commentKey], 'file.m');
- test.done();
- },
- 'should add the PBXFileReference object correctly': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- fileRefSection = proj.pbxFileReferenceSection(),
- fileRefEntry = fileRefSection[newFile.fileRef];
-
- test.equal(fileRefEntry.isa, 'PBXFileReference');
- test.equal(fileRefEntry.fileEncoding, 4);
- test.equal(fileRefEntry.lastKnownFileType, 'sourcecode.c.objc');
- test.equal(fileRefEntry.name, '"file.m"');
- test.equal(fileRefEntry.path, '"file.m"');
- test.equal(fileRefEntry.sourceTree, '"<group>"');
-
- test.done();
- },
- 'should add to the Plugins PBXGroup group': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- plugins = proj.pbxGroupByName('Plugins');
-
- test.equal(plugins.children.length, 1);
- test.done();
- },
- 'should have the right values for the PBXGroup entry': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- plugins = proj.pbxGroupByName('Plugins'),
- pluginObj = plugins.children[0];
-
- test.equal(pluginObj.comment, 'file.m');
- test.equal(pluginObj.value, newFile.fileRef);
- test.done();
- },
- 'should add to the PBXSourcesBuildPhase': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- sources = proj.pbxSourcesBuildPhaseObj();
-
- test.equal(sources.files.length, 3);
- test.done();
- },
- 'should have the right values for the Sources entry': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- sources = proj.pbxSourcesBuildPhaseObj(),
- sourceObj = sources.files[2];
-
- test.equal(sourceObj.comment, 'file.m in Sources');
- test.equal(sourceObj.value, newFile.uuid);
- test.done();
- },
- 'duplicate entries': {
- 'should return false': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m');
-
- test.ok(!proj.addSourceFile('Plugins/file.m'));
- test.done();
- },
- 'should not add another entry anywhere': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- buildFileSection = proj.pbxBuildFileSection(),
- bfsLength = Object.keys(buildFileSection).length,
- fileRefSection = proj.pbxFileReferenceSection(),
- frsLength = Object.keys(fileRefSection).length,
- plugins = proj.pbxGroupByName('Plugins'),
- sources = proj.pbxSourcesBuildPhaseObj();
-
- // duplicate!
- proj.addSourceFile('Plugins/file.m');
-
- test.equal(60, bfsLength); // BuildFileSection
- test.equal(68, frsLength); // FileReferenceSection
- test.equal(plugins.children.length, 1); // Plugins pbxGroup
- test.equal(sources.files.length, 3); // SourcesBuildPhhase
- test.done();
- }
- }
-}
-
+ });
+
+ it('should return a pbxFile', () => {
+ const newFile = proj.addSourceFile('file.m');
+ assert.strictEqual(newFile.constructor, pbxFile);
+ });
+
+ it('should set a uuid on the pbxFile', () => {
+ const newFile = proj.addSourceFile('file.m');
+ assert.ok(newFile.uuid);
+ });
+
+ it('should set a fileRef on the pbxFile', () => {
+ const newFile = proj.addSourceFile('file.m');
+ assert.ok(newFile.fileRef);
+ });
+
+ it('should populate the PBXBuildFile section with 2 fields', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const buildFileSection = proj.pbxBuildFileSection();
+ const bfsLength = Object.keys(buildFileSection).length;
+
+ assert.strictEqual(bfsLength, 60);
+ assert.ok(buildFileSection[newFile.uuid]);
+ assert.ok(buildFileSection[newFile.uuid + '_comment']);
+ });
+
+ it('should add the PBXBuildFile comment correctly', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const commentKey = newFile.uuid + '_comment';
+ const buildFileSection = proj.pbxBuildFileSection();
+
+ assert.strictEqual(buildFileSection[commentKey], 'file.m in Sources');
+ });
+
+ it('should add the PBXBuildFile object correctly', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const buildFileSection = proj.pbxBuildFileSection();
+ const buildFileEntry = buildFileSection[newFile.uuid];
+
+ assert.strictEqual(buildFileEntry.isa, 'PBXBuildFile');
+ assert.strictEqual(buildFileEntry.fileRef, newFile.fileRef);
+ assert.strictEqual(buildFileEntry.fileRef_comment, 'file.m');
+ });
+
+ it('should populate the PBXFileReference section with 2 fields', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const fileRefSection = proj.pbxFileReferenceSection();
+ const frsLength = Object.keys(fileRefSection).length;
+
+ assert.strictEqual(frsLength, 68);
+ assert.ok(fileRefSection[newFile.fileRef]);
+ assert.ok(fileRefSection[newFile.fileRef + '_comment']);
+ });
+
+ it('should populate the PBXFileReference comment correctly', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const fileRefSection = proj.pbxFileReferenceSection();
+ const commentKey = newFile.fileRef + '_comment';
+
+ assert.strictEqual(fileRefSection[commentKey], 'file.m');
+ });
+
+ it('should add the PBXFileReference object correctly', () => {
+ const newFile = proj.addSourceFile('Plugins/file.m');
+ const fileRefSection = proj.pbxFileReferenceSection();
+ const fileRefEntry = fileRefSection[newFile.fileRef];
+
+ assert.strictEqual(fileRefEntry.isa, 'PBXFileReference');
+ assert.strictEqual(fileRefEntry.fileEncoding, 4);
+ assert.strictEqual(fileRefEntry.lastKnownFileType, 'sourcecode.c.objc');
+ assert.strictEqual(fileRefEntry.name, '"file.m"');
+ assert.strictEqual(fileRefEntry.path, '"file.m"');
+ assert.strictEqual(fileRefEntry.sourceTree, '"<group>"');
+ });
+
+ it('should add to the Plugins PBXGroup group', () => {
+ const newFile = proj.addSourceFile('Plugins/file.m');
+ const plugins = proj.pbxGroupByName('Plugins');
+ assert.strictEqual(plugins.children.length, 1);
+ });
+
+ it('should have the right values for the PBXGroup entry', () => {
+ const newFile = proj.addSourceFile('Plugins/file.m');
+ const plugins = proj.pbxGroupByName('Plugins');
+ const pluginObj = plugins.children[0];
+
+ assert.strictEqual(pluginObj.comment, 'file.m');
+ assert.strictEqual(pluginObj.value, newFile.fileRef);
+ });
+
+ it('should add to the PBXSourcesBuildPhase', () => {
+ const newFile = proj.addSourceFile('Plugins/file.m');
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable newFile.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/187)
##########
test/addHeaderFile.js:
##########
@@ -27,91 +30,82 @@
return JSON.parse(fullProjectStr);
}
-exports.setUp = function (callback) {
- proj.hash = cleanHash();
- callback();
-}
+describe('addHeaderFile', () => {
+ beforeEach(() => {
+ proj.hash = cleanHash();
+ });
-exports.addHeaderFile = {
- 'should return a pbxFile': function (test) {
+ it('should return a pbxFile', () => {
var newFile = proj.addHeaderFile('file.h');
+ assert.equal(newFile.constructor, pbxFile);
+ });
- test.equal(newFile.constructor, pbxFile);
- test.done()
- },
- 'should set a fileRef on the pbxFile': function (test) {
+ it('should set a fileRef on the pbxFile', () => {
var newFile = proj.addHeaderFile('file.h');
+ assert.ok(newFile.fileRef);
+ });
- test.ok(newFile.fileRef);
- test.done()
- },
- 'should populate the PBXFileReference section with 2 fields': function
(test) {
+ it('should populate the PBXFileReference section with 2 fields', () => {
var newFile = proj.addHeaderFile('file.h'),
fileRefSection = proj.pbxFileReferenceSection(),
frsLength = Object.keys(fileRefSection).length;
- test.equal(68, frsLength);
- test.ok(fileRefSection[newFile.fileRef]);
- test.ok(fileRefSection[newFile.fileRef + '_comment']);
+ assert.equal(68, frsLength);
+ assert.ok(fileRefSection[newFile.fileRef]);
+ assert.ok(fileRefSection[newFile.fileRef + '_comment']);
+ });
- test.done();
- },
- 'should populate the PBXFileReference comment correctly': function (test) {
+ it('should populate the PBXFileReference comment correctly', () => {
var newFile = proj.addHeaderFile('file.h'),
fileRefSection = proj.pbxFileReferenceSection(),
commentKey = newFile.fileRef + '_comment';
- test.equal(fileRefSection[commentKey], 'file.h');
- test.done();
- },
- 'should add the PBXFileReference object correctly': function (test) {
+ assert.equal(fileRefSection[commentKey], 'file.h');
+ });
+
+ it('should add the PBXFileReference object correctly', () => {
var newFile = proj.addHeaderFile('Plugins/file.h'),
fileRefSection = proj.pbxFileReferenceSection(),
fileRefEntry = fileRefSection[newFile.fileRef];
- test.equal(fileRefEntry.isa, 'PBXFileReference');
- test.equal(fileRefEntry.fileEncoding, 4);
- test.equal(fileRefEntry.lastKnownFileType, 'sourcecode.c.h');
- test.equal(fileRefEntry.name, '"file.h"');
- test.equal(fileRefEntry.path, '"file.h"');
- test.equal(fileRefEntry.sourceTree, '"<group>"');
+ assert.equal(fileRefEntry.isa, 'PBXFileReference');
+ assert.equal(fileRefEntry.fileEncoding, 4);
+ assert.equal(fileRefEntry.lastKnownFileType, 'sourcecode.c.h');
+ assert.equal(fileRefEntry.name, '"file.h"');
+ assert.equal(fileRefEntry.path, '"file.h"');
+ assert.equal(fileRefEntry.sourceTree, '"<group>"');
+ });
- test.done();
- },
- 'should add to the Plugins PBXGroup group': function (test) {
+ it('should add to the Plugins PBXGroup group', () => {
var newFile = proj.addHeaderFile('Plugins/file.h'),
plugins = proj.pbxGroupByName('Plugins');
- test.equal(plugins.children.length, 1);
- test.done();
- },
- 'should have the right values for the PBXGroup entry': function (test) {
+ assert.equal(plugins.children.length, 1);
+ });
+
+ it('should have the right values for the PBXGroup entry', () => {
var newFile = proj.addHeaderFile('Plugins/file.h'),
plugins = proj.pbxGroupByName('Plugins'),
pluginObj = plugins.children[0];
- test.equal(pluginObj.comment, 'file.h');
- test.equal(pluginObj.value, newFile.fileRef);
- test.done();
- },
- 'duplicate entries': {
- 'should return false': function (test) {
- var newFile = proj.addHeaderFile('Plugins/file.h');
-
- test.ok(!proj.addHeaderFile('Plugins/file.h'));
- test.done();
- },
- 'should not add another entry anywhere': function (test) {
- var newFile = proj.addHeaderFile('Plugins/file.h'),
- fileRefSection = proj.pbxFileReferenceSection(),
- frsLength = Object.keys(fileRefSection).length,
- plugins = proj.pbxGroupByName('Plugins');
-
- proj.addHeaderFile('Plugins/file.h');
-
- test.equal(68, frsLength);
- test.equal(plugins.children.length, 1);
- test.done();
- }
- }
-}
+ assert.equal(pluginObj.comment, 'file.h');
+ assert.equal(pluginObj.value, newFile.fileRef);
+ });
+
+ it('addHeaderFile duplicate entries: should return false', () => {
+ var newFile = proj.addHeaderFile('Plugins/file.h');
+ assert.ok(!proj.addHeaderFile('Plugins/file.h'));
+ });
+
+ it('addHeaderFile duplicate entries: should not add another entry
anywhere', () => {
+ var newFile = proj.addHeaderFile('Plugins/file.h'),
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable newFile.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/185)
##########
test/addFramework.js:
##########
@@ -61,153 +59,152 @@
return allPaths;
}
-exports.addFramework = {
- 'should return a pbxFile': function (test) {
+describe('addFramework', () => {
+ beforeEach(() => {
+ proj.hash = cleanHash();
+ });
+
+ it('should return a pbxFile', () => {
var newFile = proj.addFramework('libsqlite3.dylib');
+ assert.equal(newFile.constructor, pbxFile);
+ });
- test.equal(newFile.constructor, pbxFile);
- test.done()
- },
- 'should set a fileRef on the pbxFile': function (test) {
+ it('should set a fileRef on the pbxFile', () => {
var newFile = proj.addFramework('libsqlite3.dylib');
+ assert.ok(newFile.fileRef);
+ });
- test.ok(newFile.fileRef);
- test.done()
- },
- 'should populate the PBXFileReference section with 2 fields': function
(test) {
+ it('should populate the PBXFileReference section with 2 fields', () => {
var newFile = proj.addFramework('libsqlite3.dylib');
fileRefSection = proj.pbxFileReferenceSection(),
frsLength = Object.keys(fileRefSection).length;
- test.equal(68, frsLength);
- test.ok(fileRefSection[newFile.fileRef]);
- test.ok(fileRefSection[newFile.fileRef + '_comment']);
+ assert.equal(68, frsLength);
+ assert.ok(fileRefSection[newFile.fileRef]);
+ assert.ok(fileRefSection[newFile.fileRef + '_comment']);
+ ;
+ });
- test.done();
- },
- 'should populate the PBXFileReference comment correctly': function (test) {
+ it('should populate the PBXFileReference comment correctly', () => {
var newFile = proj.addFramework('libsqlite3.dylib');
fileRefSection = proj.pbxFileReferenceSection(),
commentKey = newFile.fileRef + '_comment';
- test.equal(fileRefSection[commentKey], 'libsqlite3.dylib');
- test.done();
- },
- 'should add the PBXFileReference object correctly': function (test) {
+ assert.equal(fileRefSection[commentKey], 'libsqlite3.dylib');
+ });
+
+ it('should add the PBXFileReference object correctly', () => {
var newFile = proj.addFramework('libsqlite3.dylib'),
fileRefSection = proj.pbxFileReferenceSection(),
fileRefEntry = fileRefSection[newFile.fileRef];
- test.equal(fileRefEntry.isa, 'PBXFileReference');
- test.equal(fileRefEntry.lastKnownFileType, 'compiled.mach-o.dylib');
- test.equal(fileRefEntry.name, '"libsqlite3.dylib"');
- test.equal(fileRefEntry.path, '"usr/lib/libsqlite3.dylib"');
- test.equal(fileRefEntry.sourceTree, 'SDKROOT');
+ assert.equal(fileRefEntry.isa, 'PBXFileReference');
+ assert.equal(fileRefEntry.lastKnownFileType, 'compiled.mach-o.dylib');
+ assert.equal(fileRefEntry.name, '"libsqlite3.dylib"');
+ assert.equal(fileRefEntry.path, '"usr/lib/libsqlite3.dylib"');
+ assert.equal(fileRefEntry.sourceTree, 'SDKROOT');
+ ;
+ });
- test.done();
- },
- 'should populate the PBXBuildFile section with 2 fields': function (test) {
+ it('should populate the PBXBuildFile section with 2 fields', () => {
var newFile = proj.addFramework('libsqlite3.dylib'),
buildFileSection = proj.pbxBuildFileSection(),
bfsLength = Object.keys(buildFileSection).length;
- test.equal(60, bfsLength);
- test.ok(buildFileSection[newFile.uuid]);
- test.ok(buildFileSection[newFile.uuid + '_comment']);
+ assert.equal(60, bfsLength);
+ assert.ok(buildFileSection[newFile.uuid]);
+ assert.ok(buildFileSection[newFile.uuid + '_comment']);
+ ;
+ });
- test.done();
- },
- 'should add the PBXBuildFile comment correctly': function (test) {
+ it('should add the PBXBuildFile comment correctly', () => {
var newFile = proj.addFramework('libsqlite3.dylib'),
commentKey = newFile.uuid + '_comment',
buildFileSection = proj.pbxBuildFileSection();
- test.equal(buildFileSection[commentKey], 'libsqlite3.dylib in
Frameworks');
- test.done();
- },
- 'should add the PBXBuildFile object correctly': function (test) {
+ assert.equal(buildFileSection[commentKey], 'libsqlite3.dylib in
Frameworks');
+ });
+
+ it('should add the PBXBuildFile object correctly', () => {
var newFile = proj.addFramework('libsqlite3.dylib'),
buildFileSection = proj.pbxBuildFileSection(),
buildFileEntry = buildFileSection[newFile.uuid];
- test.equal(buildFileEntry.isa, 'PBXBuildFile');
- test.equal(buildFileEntry.fileRef, newFile.fileRef);
- test.equal(buildFileEntry.fileRef_comment, 'libsqlite3.dylib');
- test.equal(buildFileEntry.settings, undefined);
+ assert.equal(buildFileEntry.isa, 'PBXBuildFile');
+ assert.equal(buildFileEntry.fileRef, newFile.fileRef);
+ assert.equal(buildFileEntry.fileRef_comment, 'libsqlite3.dylib');
+ assert.equal(buildFileEntry.settings, undefined);
+ ;
+ });
- test.done();
- },
- 'should add the PBXBuildFile object correctly /w weak linked frameworks':
function (test) {
+ it('should add the PBXBuildFile object correctly /w weak linked
frameworks', () => {
var newFile = proj.addFramework('libsqlite3.dylib', { weak: true }),
buildFileSection = proj.pbxBuildFileSection(),
buildFileEntry = buildFileSection[newFile.uuid];
- test.equal(buildFileEntry.isa, 'PBXBuildFile');
- test.equal(buildFileEntry.fileRef, newFile.fileRef);
- test.equal(buildFileEntry.fileRef_comment, 'libsqlite3.dylib');
- test.deepEqual(buildFileEntry.settings, { ATTRIBUTES: [ 'Weak' ] });
+ assert.equal(buildFileEntry.isa, 'PBXBuildFile');
+ assert.equal(buildFileEntry.fileRef, newFile.fileRef);
+ assert.equal(buildFileEntry.fileRef_comment, 'libsqlite3.dylib');
+ assert.deepEqual(buildFileEntry.settings, { ATTRIBUTES: [ 'Weak' ] });
+ ;
+ });
- test.done();
- },
- 'should add to the Frameworks PBXGroup': function (test) {
+ it('should add to the Frameworks PBXGroup', () => {
var newLength = proj.pbxGroupByName('Frameworks').children.length + 1,
newFile = proj.addFramework('libsqlite3.dylib'),
frameworks = proj.pbxGroupByName('Frameworks');
- test.equal(frameworks.children.length, newLength);
- test.done();
- },
- 'should have the right values for the PBXGroup entry': function (test) {
+ assert.equal(frameworks.children.length, newLength);
+ });
+
+ it('should have the right values for the PBXGroup entry', () => {
var newFile = proj.addFramework('libsqlite3.dylib'),
frameworks = proj.pbxGroupByName('Frameworks').children,
framework = frameworks[frameworks.length - 1];
- test.equal(framework.comment, 'libsqlite3.dylib');
- test.equal(framework.value, newFile.fileRef);
- test.done();
- },
- 'should add to the PBXFrameworksBuildPhase': function (test) {
+ assert.equal(framework.comment, 'libsqlite3.dylib');
+ assert.equal(framework.value, newFile.fileRef);
+ });
+
+ it('should add to the PBXFrameworksBuildPhase', () => {
var newFile = proj.addFramework('libsqlite3.dylib'),
frameworks = proj.pbxFrameworksBuildPhaseObj();
- test.equal(frameworks.files.length, 16);
- test.done();
- },
- 'should not add to the PBXFrameworksBuildPhase': function (test) {
+ assert.equal(frameworks.files.length, 16);
+ });
+
+ it('should not add to the PBXFrameworksBuildPhase', () => {
var newFile = proj.addFramework('Private.framework', {link: false}),
frameworks = proj.pbxFrameworksBuildPhaseObj();
- test.equal(frameworks.files.length, 15);
- test.done();
- },
- 'should have the right values for the Sources entry': function (test) {
+ assert.equal(frameworks.files.length, 15);
+ });
+
+ it('should have the right values for the Sources entry', () => {
var newFile = proj.addFramework('libsqlite3.dylib'),
frameworks = proj.pbxFrameworksBuildPhaseObj(),
framework = frameworks.files[15];
- test.equal(framework.comment, 'libsqlite3.dylib in Frameworks');
- test.equal(framework.value, newFile.uuid);
- test.done();
- },
- 'duplicate entries': {
- 'should return false': function (test) {
- var newFile = proj.addFramework('libsqlite3.dylib');
+ assert.equal(framework.comment, 'libsqlite3.dylib in Frameworks');
+ assert.equal(framework.value, newFile.uuid);
+ });
- test.ok(!proj.addFramework('libsqlite3.dylib'));
- test.done();
- }
- },
- 'should pbxFile correctly for custom frameworks': function (test) {
+ it('should return false', () => {
+ var newFile = proj.addFramework('libsqlite3.dylib');
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable newFile.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/183)
##########
test/addHeaderFile.js:
##########
@@ -27,91 +30,82 @@
return JSON.parse(fullProjectStr);
}
-exports.setUp = function (callback) {
- proj.hash = cleanHash();
- callback();
-}
+describe('addHeaderFile', () => {
+ beforeEach(() => {
+ proj.hash = cleanHash();
+ });
-exports.addHeaderFile = {
- 'should return a pbxFile': function (test) {
+ it('should return a pbxFile', () => {
var newFile = proj.addHeaderFile('file.h');
+ assert.equal(newFile.constructor, pbxFile);
+ });
- test.equal(newFile.constructor, pbxFile);
- test.done()
- },
- 'should set a fileRef on the pbxFile': function (test) {
+ it('should set a fileRef on the pbxFile', () => {
var newFile = proj.addHeaderFile('file.h');
+ assert.ok(newFile.fileRef);
+ });
- test.ok(newFile.fileRef);
- test.done()
- },
- 'should populate the PBXFileReference section with 2 fields': function
(test) {
+ it('should populate the PBXFileReference section with 2 fields', () => {
var newFile = proj.addHeaderFile('file.h'),
fileRefSection = proj.pbxFileReferenceSection(),
frsLength = Object.keys(fileRefSection).length;
- test.equal(68, frsLength);
- test.ok(fileRefSection[newFile.fileRef]);
- test.ok(fileRefSection[newFile.fileRef + '_comment']);
+ assert.equal(68, frsLength);
+ assert.ok(fileRefSection[newFile.fileRef]);
+ assert.ok(fileRefSection[newFile.fileRef + '_comment']);
+ });
- test.done();
- },
- 'should populate the PBXFileReference comment correctly': function (test) {
+ it('should populate the PBXFileReference comment correctly', () => {
var newFile = proj.addHeaderFile('file.h'),
fileRefSection = proj.pbxFileReferenceSection(),
commentKey = newFile.fileRef + '_comment';
- test.equal(fileRefSection[commentKey], 'file.h');
- test.done();
- },
- 'should add the PBXFileReference object correctly': function (test) {
+ assert.equal(fileRefSection[commentKey], 'file.h');
+ });
+
+ it('should add the PBXFileReference object correctly', () => {
var newFile = proj.addHeaderFile('Plugins/file.h'),
fileRefSection = proj.pbxFileReferenceSection(),
fileRefEntry = fileRefSection[newFile.fileRef];
- test.equal(fileRefEntry.isa, 'PBXFileReference');
- test.equal(fileRefEntry.fileEncoding, 4);
- test.equal(fileRefEntry.lastKnownFileType, 'sourcecode.c.h');
- test.equal(fileRefEntry.name, '"file.h"');
- test.equal(fileRefEntry.path, '"file.h"');
- test.equal(fileRefEntry.sourceTree, '"<group>"');
+ assert.equal(fileRefEntry.isa, 'PBXFileReference');
+ assert.equal(fileRefEntry.fileEncoding, 4);
+ assert.equal(fileRefEntry.lastKnownFileType, 'sourcecode.c.h');
+ assert.equal(fileRefEntry.name, '"file.h"');
+ assert.equal(fileRefEntry.path, '"file.h"');
+ assert.equal(fileRefEntry.sourceTree, '"<group>"');
+ });
- test.done();
- },
- 'should add to the Plugins PBXGroup group': function (test) {
+ it('should add to the Plugins PBXGroup group', () => {
var newFile = proj.addHeaderFile('Plugins/file.h'),
plugins = proj.pbxGroupByName('Plugins');
- test.equal(plugins.children.length, 1);
- test.done();
- },
- 'should have the right values for the PBXGroup entry': function (test) {
+ assert.equal(plugins.children.length, 1);
+ });
+
+ it('should have the right values for the PBXGroup entry', () => {
var newFile = proj.addHeaderFile('Plugins/file.h'),
plugins = proj.pbxGroupByName('Plugins'),
pluginObj = plugins.children[0];
- test.equal(pluginObj.comment, 'file.h');
- test.equal(pluginObj.value, newFile.fileRef);
- test.done();
- },
- 'duplicate entries': {
- 'should return false': function (test) {
- var newFile = proj.addHeaderFile('Plugins/file.h');
-
- test.ok(!proj.addHeaderFile('Plugins/file.h'));
- test.done();
- },
- 'should not add another entry anywhere': function (test) {
- var newFile = proj.addHeaderFile('Plugins/file.h'),
- fileRefSection = proj.pbxFileReferenceSection(),
- frsLength = Object.keys(fileRefSection).length,
- plugins = proj.pbxGroupByName('Plugins');
-
- proj.addHeaderFile('Plugins/file.h');
-
- test.equal(68, frsLength);
- test.equal(plugins.children.length, 1);
- test.done();
- }
- }
-}
+ assert.equal(pluginObj.comment, 'file.h');
+ assert.equal(pluginObj.value, newFile.fileRef);
+ });
+
+ it('addHeaderFile duplicate entries: should return false', () => {
+ var newFile = proj.addHeaderFile('Plugins/file.h');
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable newFile.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/184)
##########
test/pbxFile.js:
##########
@@ -17,276 +17,251 @@
under the License.
*/
+const { describe, it, beforeEach } = require('node:test');
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable beforeEach.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/188)
##########
test/addRemovePbxGroup.js:
##########
@@ -26,154 +29,146 @@
return JSON.parse(fullProjectStr);
}
-exports.setUp = function (callback) {
- proj.hash = cleanHash();
- callback();
-}
+describe('addRemovePbxGroup', () => {
+ beforeEach(() => {
+ proj.hash = cleanHash();
+ });
-exports.addRemovePbxGroup = {
- 'should return a pbxGroup': function (test) {
+ it('should return a pbxGroup', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'Application', '"<group>"');
+ assert.ok(typeof pbxGroup === 'object');
+ });
- test.ok(typeof pbxGroup === 'object');
- test.done()
- },
- 'should set a uuid on the pbxGroup': function (test) {
+ it('should set a uuid on the pbxGroup', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'Application', '"<group>"');
+ assert.ok(pbxGroup.uuid);
+ });
- test.ok(pbxGroup.uuid);
- test.done()
- },
- 'should add all files to pbxGroup': function (test) {
+ it('should add all files to pbxGroup', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'Application', '"<group>"');
for (var index = 0; index < pbxGroup.pbxGroup.children.length;
index++) {
var file = pbxGroup.pbxGroup.children[index];
- test.ok(file.value);
+ assert.ok(file.value);
}
+ });
- test.done()
- },
- 'should add the PBXGroup object correctly': function (test) {
+ it('should add the PBXGroup object correctly', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application',
'"<group>"');
- pbxGroupInPbx = proj.pbxGroupByName('MyGroup');
-
- test.equal(pbxGroupInPbx.children, pbxGroup.pbxGroup.children);
- test.equal(pbxGroupInPbx.isa, 'PBXGroup');
- test.equal(pbxGroupInPbx.path, 'Application');
- test.equal(pbxGroupInPbx.sourceTree, '"<group>"');
- test.done();
- },
- 'should add <group> sourceTree if no other specified': function (test) {
+ pbxGroupInPbx = proj.pbxGroupByName('MyGroup');
+
+ assert.equal(pbxGroupInPbx.children, pbxGroup.pbxGroup.children);
+ assert.equal(pbxGroupInPbx.isa, 'PBXGroup');
+ assert.equal(pbxGroupInPbx.path, 'Application');
+ assert.equal(pbxGroupInPbx.sourceTree, '"<group>"');
+ });
+
+ it('should add <group> sourceTree if no other specified', () => {
var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application');
- pbxGroupInPbx = proj.pbxGroupByName('MyGroup');
+ pbxGroupInPbx = proj.pbxGroupByName('MyGroup');
Review Comment:
## CodeQL / Missing variable declaration
Variable pbxGroupInPbx is used like a local variable, but is missing a
declaration.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/182)
##########
test/addSourceFile.js:
##########
@@ -27,150 +29,135 @@
return JSON.parse(fullProjectStr);
}
-exports.setUp = function (callback) {
+describe('addSourceFile', () => {
+ beforeEach(() => {
proj.hash = cleanHash();
- callback();
-}
-
-exports.addSourceFile = {
- 'should return a pbxFile': function (test) {
- var newFile = proj.addSourceFile('file.m');
-
- test.equal(newFile.constructor, pbxFile);
- test.done()
- },
- 'should set a uuid on the pbxFile': function (test) {
- var newFile = proj.addSourceFile('file.m');
-
- test.ok(newFile.uuid);
- test.done()
- },
- 'should set a fileRef on the pbxFile': function (test) {
- var newFile = proj.addSourceFile('file.m');
-
- test.ok(newFile.fileRef);
- test.done()
- },
- 'should populate the PBXBuildFile section with 2 fields': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- buildFileSection = proj.pbxBuildFileSection(),
- bfsLength = Object.keys(buildFileSection).length;
-
- test.equal(60, bfsLength);
- test.ok(buildFileSection[newFile.uuid]);
- test.ok(buildFileSection[newFile.uuid + '_comment']);
-
- test.done();
- },
- 'should add the PBXBuildFile comment correctly': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- commentKey = newFile.uuid + '_comment',
- buildFileSection = proj.pbxBuildFileSection();
-
- test.equal(buildFileSection[commentKey], 'file.m in Sources');
- test.done();
- },
- 'should add the PBXBuildFile object correctly': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- buildFileSection = proj.pbxBuildFileSection(),
- buildFileEntry = buildFileSection[newFile.uuid];
-
- test.equal(buildFileEntry.isa, 'PBXBuildFile');
- test.equal(buildFileEntry.fileRef, newFile.fileRef);
- test.equal(buildFileEntry.fileRef_comment, 'file.m');
-
- test.done();
- },
- 'should populate the PBXFileReference section with 2 fields': function
(test) {
- var newFile = proj.addSourceFile('file.m'),
- fileRefSection = proj.pbxFileReferenceSection(),
- frsLength = Object.keys(fileRefSection).length;
-
- test.equal(68, frsLength);
- test.ok(fileRefSection[newFile.fileRef]);
- test.ok(fileRefSection[newFile.fileRef + '_comment']);
-
- test.done();
- },
- 'should populate the PBXFileReference comment correctly': function (test) {
- var newFile = proj.addSourceFile('file.m'),
- fileRefSection = proj.pbxFileReferenceSection(),
- commentKey = newFile.fileRef + '_comment';
-
- test.equal(fileRefSection[commentKey], 'file.m');
- test.done();
- },
- 'should add the PBXFileReference object correctly': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- fileRefSection = proj.pbxFileReferenceSection(),
- fileRefEntry = fileRefSection[newFile.fileRef];
-
- test.equal(fileRefEntry.isa, 'PBXFileReference');
- test.equal(fileRefEntry.fileEncoding, 4);
- test.equal(fileRefEntry.lastKnownFileType, 'sourcecode.c.objc');
- test.equal(fileRefEntry.name, '"file.m"');
- test.equal(fileRefEntry.path, '"file.m"');
- test.equal(fileRefEntry.sourceTree, '"<group>"');
-
- test.done();
- },
- 'should add to the Plugins PBXGroup group': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- plugins = proj.pbxGroupByName('Plugins');
-
- test.equal(plugins.children.length, 1);
- test.done();
- },
- 'should have the right values for the PBXGroup entry': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- plugins = proj.pbxGroupByName('Plugins'),
- pluginObj = plugins.children[0];
-
- test.equal(pluginObj.comment, 'file.m');
- test.equal(pluginObj.value, newFile.fileRef);
- test.done();
- },
- 'should add to the PBXSourcesBuildPhase': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- sources = proj.pbxSourcesBuildPhaseObj();
-
- test.equal(sources.files.length, 3);
- test.done();
- },
- 'should have the right values for the Sources entry': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- sources = proj.pbxSourcesBuildPhaseObj(),
- sourceObj = sources.files[2];
-
- test.equal(sourceObj.comment, 'file.m in Sources');
- test.equal(sourceObj.value, newFile.uuid);
- test.done();
- },
- 'duplicate entries': {
- 'should return false': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m');
-
- test.ok(!proj.addSourceFile('Plugins/file.m'));
- test.done();
- },
- 'should not add another entry anywhere': function (test) {
- var newFile = proj.addSourceFile('Plugins/file.m'),
- buildFileSection = proj.pbxBuildFileSection(),
- bfsLength = Object.keys(buildFileSection).length,
- fileRefSection = proj.pbxFileReferenceSection(),
- frsLength = Object.keys(fileRefSection).length,
- plugins = proj.pbxGroupByName('Plugins'),
- sources = proj.pbxSourcesBuildPhaseObj();
-
- // duplicate!
- proj.addSourceFile('Plugins/file.m');
-
- test.equal(60, bfsLength); // BuildFileSection
- test.equal(68, frsLength); // FileReferenceSection
- test.equal(plugins.children.length, 1); // Plugins pbxGroup
- test.equal(sources.files.length, 3); // SourcesBuildPhhase
- test.done();
- }
- }
-}
-
+ });
+
+ it('should return a pbxFile', () => {
+ const newFile = proj.addSourceFile('file.m');
+ assert.strictEqual(newFile.constructor, pbxFile);
+ });
+
+ it('should set a uuid on the pbxFile', () => {
+ const newFile = proj.addSourceFile('file.m');
+ assert.ok(newFile.uuid);
+ });
+
+ it('should set a fileRef on the pbxFile', () => {
+ const newFile = proj.addSourceFile('file.m');
+ assert.ok(newFile.fileRef);
+ });
+
+ it('should populate the PBXBuildFile section with 2 fields', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const buildFileSection = proj.pbxBuildFileSection();
+ const bfsLength = Object.keys(buildFileSection).length;
+
+ assert.strictEqual(bfsLength, 60);
+ assert.ok(buildFileSection[newFile.uuid]);
+ assert.ok(buildFileSection[newFile.uuid + '_comment']);
+ });
+
+ it('should add the PBXBuildFile comment correctly', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const commentKey = newFile.uuid + '_comment';
+ const buildFileSection = proj.pbxBuildFileSection();
+
+ assert.strictEqual(buildFileSection[commentKey], 'file.m in Sources');
+ });
+
+ it('should add the PBXBuildFile object correctly', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const buildFileSection = proj.pbxBuildFileSection();
+ const buildFileEntry = buildFileSection[newFile.uuid];
+
+ assert.strictEqual(buildFileEntry.isa, 'PBXBuildFile');
+ assert.strictEqual(buildFileEntry.fileRef, newFile.fileRef);
+ assert.strictEqual(buildFileEntry.fileRef_comment, 'file.m');
+ });
+
+ it('should populate the PBXFileReference section with 2 fields', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const fileRefSection = proj.pbxFileReferenceSection();
+ const frsLength = Object.keys(fileRefSection).length;
+
+ assert.strictEqual(frsLength, 68);
+ assert.ok(fileRefSection[newFile.fileRef]);
+ assert.ok(fileRefSection[newFile.fileRef + '_comment']);
+ });
+
+ it('should populate the PBXFileReference comment correctly', () => {
+ const newFile = proj.addSourceFile('file.m');
+ const fileRefSection = proj.pbxFileReferenceSection();
+ const commentKey = newFile.fileRef + '_comment';
+
+ assert.strictEqual(fileRefSection[commentKey], 'file.m');
+ });
+
+ it('should add the PBXFileReference object correctly', () => {
+ const newFile = proj.addSourceFile('Plugins/file.m');
+ const fileRefSection = proj.pbxFileReferenceSection();
+ const fileRefEntry = fileRefSection[newFile.fileRef];
+
+ assert.strictEqual(fileRefEntry.isa, 'PBXFileReference');
+ assert.strictEqual(fileRefEntry.fileEncoding, 4);
+ assert.strictEqual(fileRefEntry.lastKnownFileType, 'sourcecode.c.objc');
+ assert.strictEqual(fileRefEntry.name, '"file.m"');
+ assert.strictEqual(fileRefEntry.path, '"file.m"');
+ assert.strictEqual(fileRefEntry.sourceTree, '"<group>"');
+ });
+
+ it('should add to the Plugins PBXGroup group', () => {
+ const newFile = proj.addSourceFile('Plugins/file.m');
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable newFile.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/186)
##########
test/group.js:
##########
@@ -75,404 +78,379 @@
return found;
}
-exports.setUp = function(callback) {
- project = new pbx('test/parser/projects/group.pbxproj');
- projectHash = project.parseSync();
- callback();
-}
-
-exports.getGroupByKey = {
- 'should return PBXGroup for Classes': function(test) {
- var groupKey = project.findPBXGroupKey({name: 'Classes'});
- var group = project.getPBXGroupByKey(groupKey);
- test.ok(group.name === 'Classes');
- test.done();
- },
- 'should return PBXGroup for Plugins': function(test) {
- var groupKey = project.findPBXGroupKey({name: 'Plugins'});
- var group = project.getPBXGroupByKey(groupKey);
- test.ok(group.name === 'Plugins');
- test.done();
- }
-}
-
-exports.createGroup = {
- 'should create a new Test Group': function(test) {
- var found = false;
- var groups = project.getPBXObject('PBXGroup');
+describe('group', () => {
+ beforeEach(() => {
+ project = new pbx('test/parser/projects/group.pbxproj');
+ projectHash = project.parseSync();
+ });
+
+ describe('getGroupByKey', () => {
+ it('should return PBXGroup for Classes', () => {
+ var groupKey = project.findPBXGroupKey({name: 'Classes'});
+ var group = project.getPBXGroupByKey(groupKey);
+ assert.ok(group.name === 'Classes');
+ });
+
+ it('should return PBXGroup for Plugins', () => {
+ var groupKey = project.findPBXGroupKey({name: 'Plugins'});
+ var group = project.getPBXGroupByKey(groupKey);
+ assert.ok(group.name === 'Plugins');
+ });
+ });
+
+ describe('createGroup', () => {
+ it('should create a new Test Group', () => {
+ var found = false;
+ var groups = project.getPBXObject('PBXGroup');
+
+ var found = findByName(groups, 'Test');
+ assert.ok(found === false);
+
+
+ var group = project.findPBXGroupKey({name:'Test'});
+ assert.ok(group === undefined);
+
+ project.pbxCreateGroup('Test', 'Test');
+
+ groups = project.getPBXObject('PBXGroup');
+ found = findByName(groups, 'Test');
+ assert.ok(found === true);
+
+ group = project.findPBXGroupKey({name:'Test'});
+ assert.ok(typeof group === 'string');
+ });
+ });
+
+ describe('findGroupKey', () => {
+ it('should return a valid group key', () => {
+ var keyByName = project.findPBXGroupKey({ name: 'Classes'});
+ var keyByPath = project.findPBXGroupKey({ path: 'icons'});
+ var keyByPathName = project.findPBXGroupKey({ path:
'"HelloCordova/Plugins"', name: 'Plugins'});
+ var nonExistingKey = project.findPBXGroupKey({ name: 'Foo'});
+
+ assert.ok(keyByName === '080E96DDFE201D6D7F000001');
+ assert.ok(keyByPath === '308D052D1370CCF300D202BF');
+ assert.ok(keyByPathName === '307C750510C5A3420062BCA9');
+ assert.ok(nonExistingKey === undefined);
+
+ });
+ });
+
+ describe('addGroupToGroup', () => {
+ it('should create a new test group then add group to Classes group',
() => {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var classesKey = project.findPBXGroupKey({name: 'Classes'});
+ project.addToPbxGroup(testKey, classesKey);
+
+ var classesGroup = project.getPBXGroupByKey(classesKey);
+ var foundTestGroup = false;
+ for (var i = 0, j = classesGroup.children.length; i < j; i++) {
+ var child = classesGroup.children[i];
+ if (child.value === testKey && child.comment === 'Test') {
+ foundTestGroup = true;
+ }
+ }
- var found = findByName(groups, 'Test');
- test.ok(found === false);
+ assert.ok(foundTestGroup);
+ });
+ });
- var group = project.findPBXGroupKey({name:'Test'});
- test.ok(group === undefined);
+ describe('predefinedPbxGroups', () => {
+ beforeEach(() => {
+ project = new
pbx('test/parser/projects/empty-groups.pbxproj').parseSync();
- project.pbxCreateGroup('Test', 'Test');
+ this.file = new pbxFile('some-file.m');
+ this.file.fileRef = project.generateUuid();
+ project.addToPbxFileReferenceSection(this.file);
+ });
- groups = project.getPBXObject('PBXGroup');
- found = findByName(groups, 'Test');
- test.ok(found === true);
+ it('should add a file to "Plugins" group', () => {
+ project.addToPluginsPbxGroup(this.file);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Plugins'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
- group = project.findPBXGroupKey({name:'Test'});
- test.ok(typeof group === 'string');
- test.done();
- }
-}
+ it('should remove a file from "Plugins" group', () => {
+ project.addToPluginsPbxGroup(this.file);
+ project.removeFromPluginsPbxGroup(this.file);
-exports.findGroupKey = {
- 'should return a valid group key':function(test) {
- var keyByName = project.findPBXGroupKey({ name: 'Classes'});
- var keyByPath = project.findPBXGroupKey({ path: 'icons'});
- var keyByPathName = project.findPBXGroupKey({ path:
'"HelloCordova/Plugins"', name: 'Plugins'});
- var nonExistingKey = project.findPBXGroupKey({ name: 'Foo'});
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Plugins'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
- test.ok(keyByName === '080E96DDFE201D6D7F000001');
- test.ok(keyByPath === '308D052D1370CCF300D202BF');
- test.ok(keyByPathName === '307C750510C5A3420062BCA9');
- test.ok(nonExistingKey === undefined);
+ it('should add a file to "Resources" group', () => {
+ project.addToResourcesPbxGroup(this.file);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
-exports.addGroupToGroup = {
- 'should create a new test group then add group to Classes group':
function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var classesKey = project.findPBXGroupKey({name: 'Classes'});
- project.addToPbxGroup(testKey, classesKey);
-
- var classesGroup = project.getPBXGroupByKey(classesKey);
- var foundTestGroup = false;
- for (var i = 0, j = classesGroup.children.length; i < j; i++) {
- var child = classesGroup.children[i];
- if (child.value === testKey && child.comment === 'Test') {
- foundTestGroup = true;
- }
- }
+ it('should remove a file from "Resources" group', () => {
+ project.addToResourcesPbxGroup(this.file);
+ project.removeFromResourcesPbxGroup(this.file);
- test.ok(foundTestGroup);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
- test.done();
- }
-}
+ it('should add a file to "Frameworks" group', () => {
+ project.addToFrameworksPbxGroup(this.file);
-exports.predefinedPbxGroups = {
- setUp: function(callback) {
- project = new
pbx('test/parser/projects/empty-groups.pbxproj').parseSync();
-
- this.file = new pbxFile('some-file.m');
- this.file.fileRef = project.generateUuid();
- project.addToPbxFileReferenceSection(this.file);
-
- callback();
- },
-
- 'should add a file to "Plugins" group': function(test) {
- project.addToPluginsPbxGroup(this.file);
- var foundInGroup = findChildInGroup(project.pbxGroupByName('Plugins'),
this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Plugins" group': function(test) {
- project.addToPluginsPbxGroup(this.file);
- project.removeFromPluginsPbxGroup(this.file);
-
- var foundInGroup = findChildInGroup(project.pbxGroupByName('Plugins'),
this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- },
-
- 'should add a file to "Resources" group': function(test) {
- project.addToResourcesPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Resources" group': function(test) {
- project.addToResourcesPbxGroup(this.file);
- project.removeFromResourcesPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- },
-
- 'should add a file to "Frameworks" group': function(test) {
- project.addToFrameworksPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Frameworks" group': function(test) {
- project.addToFrameworksPbxGroup(this.file);
- project.removeFromFrameworksPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- },
-
- 'should add a file to "Products" group': function(test) {
- project.addToProductsPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Products" group': function(test) {
- project.addToProductsPbxGroup(this.file);
- project.removeFromProductsPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- }
-};
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
-exports.addSourceFileToGroup = {
- 'should create group + add source file' : function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addSourceFile('Notifications.m', {}, testKey);
+ it('should remove a file from "Frameworks" group', () => {
+ project.addToFrameworksPbxGroup(this.file);
+ project.removeFromFrameworksPbxGroup(this.file);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
- var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
- test.ok(foundInBuildFileSection);
+ it('should add a file to "Products" group', () => {
+ project.addToProductsPbxGroup(this.file);
- var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
- test.ok(foundInBuildPhase);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
- test.done();
- }
-}
+ it('should remove a file from "Products" group', () => {
+ project.addToProductsPbxGroup(this.file);
+ project.removeFromProductsPbxGroup(this.file);
-exports.removeSourceFileFromGroup = {
- 'should create group + add source file then remove source file' :
function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addSourceFile('Notifications.m', {}, testKey);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
+ });
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ describe('addSourceFileToGroup', () => {
+ it('should create group + add source file', () => {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addSourceFile('Notifications.m', {}, testKey);
- var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
- test.ok(foundInBuildFileSection);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
- var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
- test.ok(foundInBuildPhase);
+ var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
+ assert.ok(foundInBuildFileSection);
- project.removeSourceFile('Notifications.m', {}, testKey);
+ var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
+ assert.ok(foundInBuildPhase);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(!foundInGroup);
+ });
+ });
- var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
- test.ok(!foundInBuildFileSection);
+ describe('removeSourceFileFromGroup', () => {
+ it('should create group + add source file then remove source file', ()
=> {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addSourceFile('Notifications.m', {}, testKey);
- var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
- test.ok(!foundInBuildPhase);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
- test.done();
- }
-}
+ var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
+ assert.ok(foundInBuildFileSection);
-exports.addHeaderFileToGroup = {
- 'should create group + add header file' : function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addHeaderFile('Notifications.h', {}, testKey);
+ var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
+ assert.ok(foundInBuildPhase);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ project.removeSourceFile('Notifications.m', {}, testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(!foundInGroup);
-exports.removeHeaderFileFromGroup = {
- 'should create group + add source file then remove header file' :
function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addHeaderFile('Notifications.h', {}, testKey);
+ var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
+ assert.ok(!foundInBuildFileSection);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
+ assert.ok(!foundInBuildPhase);
- project.removeHeaderFile('Notifications.h', {}, testKey);
+ });
+ });
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(!foundInGroup);
+ describe('addHeaderFileToGroup', () => {
+ it('should create group + add header file', () => {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addHeaderFile('Notifications.h', {}, testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
-exports.addResourceFileToGroup = {
- 'should add resource file (PNG) to the splash group' : function(test) {
+ });
+ });
- var testKey = project.findPBXGroupKey({path:'splash'});
- var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
+ describe('removeHeaderFileFromGroup', () => {
+ it('should create group + add source file then remove header file', ()
=> {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addHeaderFile('Notifications.h', {}, testKey);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
- test.done();
- }
-}
+ project.removeHeaderFile('Notifications.h', {}, testKey);
-exports.removeResourceFileFromGroup = {
- 'should add resource file (PNG) then remove resource file from splash
group' : function(test) {
- var testKey = project.findPBXGroupKey({path:'splash'});
- var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(!foundInGroup);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ });
+ });
- project.removeResourceFile('DefaultTest-667h.png', {}, testKey);
+ describe('addResourceFileToGroup', () => {
+ it('should add resource file (PNG) to the splash group', () => {
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(!foundInGroup);
+ var testKey = project.findPBXGroupKey({path:'splash'});
+ var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
-exports.retrieveBuildPropertyForBuild = {
- 'should retrieve valid build property ':function(test) {
- var releaseTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Release');
- var debugTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Debug');
- var nonExistingProperty = project.getBuildProperty('FOO', 'Debug');
- var nonExistingBuild =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Foo');
+ });
+ });
- test.equal(releaseTargetedDeviceFamily, '"1,2"');
- test.equal(debugTargetedDeviceFamily,'"1"');
- test.equal(nonExistingProperty, undefined);
- test.equal(nonExistingBuild, undefined);
+ describe('removeResourceFileFromGroup', () => {
+ it('should add resource file (PNG) then remove resource file from
splash group', () => {
+ var testKey = project.findPBXGroupKey({path:'splash'});
+ var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
-exports.retrieveBuildConfigByName = {
- 'should retrieve valid build config':function(test) {
- var releaseBuildConfig = project.getBuildConfigByName('Release');
- for (var property in releaseBuildConfig) {
- var value = releaseBuildConfig[property];
- test.ok(value.name === 'Release');
- }
+ project.removeResourceFile('DefaultTest-667h.png', {}, testKey);
- var debugBuildConfig = project.getBuildConfigByName('Debug');
- for (var property in debugBuildConfig) {
- var value = debugBuildConfig[property];
- test.ok(value.name === 'Debug');
- }
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(!foundInGroup);
- var nonExistingBuildConfig = project.getBuildConfigByName('Foo');
- test.deepEqual(nonExistingBuildConfig, {});
+ });
+ });
- test.done();
- }
-}
+ describe('retrieveBuildPropertyForBuild', () => {
+ it('should retrieve valid build property ', () => {
+ var releaseTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Release');
+ var debugTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Debug');
+ var nonExistingProperty = project.getBuildProperty('FOO', 'Debug');
+ var nonExistingBuild =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Foo');
-/* This proves the issue in 0.6.7
-exports.validatePropReplaceException = {
- 'should throw TypeError for updateBuildProperty VALID_ARCHS when none
existed' : function(test) {
- test.throws(
- function() {
- project.updateBuildProperty('VALID_ARCHS', '"armv7 armv7s');
- },
- TypeError,
- "Object object has no method 'hasOwnProperty'"
- );
- test.done();
- }
-}
-*/
+ assert.equal(releaseTargetedDeviceFamily, '"1,2"');
+ assert.equal(debugTargetedDeviceFamily,'"1"');
+ assert.equal(nonExistingProperty, undefined);
+ assert.equal(nonExistingBuild, undefined);
-exports.validatePropReplaceFix = {
- 'should create build configuration for VALID_ARCHS when none existed' :
function(test) {
- project.updateBuildProperty('VALID_ARCHS', '"armv7 armv7s"', 'Debug');
- test.done();
- }
-}
+ });
+ });
-exports.validateHasFile = {
- 'should return true for has file MainViewController.m': function(test) {
- var result = project.hasFile('MainViewController.m');
- test.ok(result.path == "MainViewController.m");
- test.done();
- }
-}
+ describe('retrieveBuildConfigByName', () => {
+ it('should retrieve valid build config', () => {
+ var releaseBuildConfig = project.getBuildConfigByName('Release');
+ for (var property in releaseBuildConfig) {
+ var value = releaseBuildConfig[property];
+ assert.ok(value.name === 'Release');
+ }
-exports.testWritingPBXProject = {
- 'should successfully write to PBXProject TargetAttributes': function(test)
{
- var pbxProjectObj = project.getPBXObject('PBXProject');
- var pbxProject;
- for (var property in pbxProjectObj) {
- if (!/comment/.test(property)) {
- pbxProject = pbxProjectObj[property];
+ var debugBuildConfig = project.getBuildConfigByName('Debug');
+ for (var property in debugBuildConfig) {
+ var value = debugBuildConfig[property];
+ assert.ok(value.name === 'Debug');
}
- }
- var target;
- var projectTargets = pbxProject.targets;
- for (var i = 0, j = pbxProject.targets.length; i < j; i++ ) {
- target = pbxProject.targets[i].value;
- }
+ var nonExistingBuildConfig = project.getBuildConfigByName('Foo');
+ assert.deepEqual(nonExistingBuildConfig, {});
- pbxProject.attributes.TargetAttributes = {};
- pbxProject.attributes.TargetAttributes[target] = {
- DevelopmentTeam: 'N6X4RJZZ5D',
- SystemCapabilities: {
- "com.apple.BackgroundModes": {
- enabled : 0
- },
- "com.apple.DataProtection" : {
- enabled : 0
+ });
+ });
+
+ /* This proves the issue in 0.6.7
+ describe('validatePropReplaceException', () => {
+ it('should throw TypeError for updateBuildProperty VALID_ARCHS when
none existed', () => {
+ assert.throws(
+ function() {
+ project.updateBuildProperty('VALID_ARCHS', '"armv7
armv7s');
},
- "com.apple.Keychain" : {
- enabled: 1
+ TypeError,
+ "Object object has no method 'hasOwnProperty'"
+ );
+ });
+ }
+ */
+
+ describe('validatePropReplaceFix', () => {
+ it('should create build configuration for VALID_ARCHS when none
existed', () => {
+ project.updateBuildProperty('VALID_ARCHS', '"armv7 armv7s"',
'Debug');
+ });
+ });
+
+ describe('validateHasFile', () => {
+ it('should return true for has file MainViewController.m', () => {
+ var result = project.hasFile('MainViewController.m');
+ assert.ok(result.path == "MainViewController.m");
+ });
+ });
+
+ describe('testWritingPBXProject', () => {
+ it('should successfully write to PBXProject TargetAttributes', () => {
+ var pbxProjectObj = project.getPBXObject('PBXProject');
+ var pbxProject;
+ for (var property in pbxProjectObj) {
+ if (!/comment/.test(property)) {
+ pbxProject = pbxProjectObj[property];
}
}
- };
-
- var output = project.writeSync();
-
- test.done();
- },
- 'should add target attribute to PBXProject TargetAttributes':
function(test) {
- project.addTargetAttribute('ProvisioningStyle', 'Manual');
- var output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
-
- test.done();
- },
- 'should change target attribute at PBXProject TargetAttributes':
function(test) {
- project.addTargetAttribute('ProvisioningStyle', 'Manual');
- var output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
-
- project.addTargetAttribute('ProvisioningStyle', 'Automatic');
- output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
- test.equal(output.match(/ProvisioningStyle\s*=\s*Automatic/g).length,
1);
-
- test.done();
- },
- 'should remove target attribute from PBXProject TargetAttributes':
function(test) {
- project.addTargetAttribute('ProvisioningStyle', 'Manual');
- var output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
-
- project.removeTargetAttribute('ProvisioningStyle');
- output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
-
- test.done();
- }
-}
+
+ var target;
+ var projectTargets = pbxProject.targets;
+ for (var i = 0, j = pbxProject.targets.length; i < j; i++ ) {
+ target = pbxProject.targets[i].value;
+ }
+
+ pbxProject.attributes.TargetAttributes = {};
+ pbxProject.attributes.TargetAttributes[target] = {
+ DevelopmentTeam: 'N6X4RJZZ5D',
+ SystemCapabilities: {
+ "com.apple.BackgroundModes": {
+ enabled : 0
+ },
+ "com.apple.DataProtection" : {
+ enabled : 0
+ },
+ "com.apple.Keychain" : {
+ enabled: 1
+ }
+ }
+ };
+
+ var output = project.writeSync();
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable output.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/190)
##########
test/variantGroup.js:
##########
@@ -74,123 +77,115 @@
return found;
}
-exports.setUp = function(callback) {
- project = new pbx('test/parser/projects/variantgroup.pbxproj');
- projectHash = project.parseSync();
- callback();
-}
-
-exports.getVariantGroupByKey = {
- 'should return PBXVariantGroup for Localizable.strings': function(test) {
- var groupKey = project.findPBXVariantGroupKey({name:
'Localizable.strings'});
- var group = project.getPBXVariantGroupByKey(groupKey);
- test.ok(group.name === 'Localizable.strings');
- test.done();
- }
-}
-
-exports.createVariantGroup = {
- 'should create a new Test Variant Group': function(test) {
- delete project.getPBXObject('PBXVariantGroup');
-
- var found = false;
- var groups = project.getPBXObject('PBXVariantGroup');
-
- var found = findByName(groups, 'Test');
- test.ok(found === false);
-
- var group = project.findPBXVariantGroupKey({name:'Test'});
- test.ok(group === undefined);
-
- project.pbxCreateVariantGroup('Test');
-
- groups = project.getPBXObject('PBXVariantGroup');
- found = findByName(groups, 'Test');
- test.ok(found === true);
-
- group = project.findPBXVariantGroupKey({name:'Test'});
- test.ok(typeof group === 'string');
- test.done();
- }
-}
-
-exports.findVariantGroupKey = {
- 'should return a valid group key':function(test) {
- var keyByName = project.findPBXVariantGroupKey({ name:
'Localizable.strings'});
- var nonExistingKey = project.findPBXVariantGroupKey({ name: 'Foo'});
-
- test.ok(keyByName === '07E3BDBC1DF1DEA500E49912');
- test.ok(nonExistingKey === undefined);
-
- test.done();
- }
-}
-exports.createLocalisationVariantGroup = {
- 'should create a new localisation variationgroup then add group to
Resources group': function(test) {
- delete project.getPBXObject('PBXVariantGroup');
-
- var localizationVariantGp =
project.addLocalizationVariantGroup('InfoPlist.strings');
-
- var resourceGroupKey = project.findPBXGroupKey({name: 'Resources'});
- var resourceGroup = project.getPBXGroupByKey(resourceGroupKey);
- var foundInResourcesGroup = findChildInGroup(resourceGroup,
localizationVariantGp.fileRef );
- test.ok(foundInResourcesGroup);
-
- var foundInResourcesBuildPhase = false;
- var sources = project.pbxResourcesBuildPhaseObj();
- for (var i = 0, j = sources.files.length; i < j; i++) {
- var file = sources.files[i];
- if (file.value === localizationVariantGp.uuid) {
- foundInResourcesBuildPhase = true;
+describe('variantGroup', () => {
+ beforeEach(() => {
+ project = new pbx('test/parser/projects/variantgroup.pbxproj');
+ projectHash = project.parseSync();
+ });
+
+ describe('getVariantGroupByKey', () => {
+ it('should return PBXVariantGroup for Localizable.strings', () => {
+ var groupKey = project.findPBXVariantGroupKey({name:
'Localizable.strings'});
+ var group = project.getPBXVariantGroupByKey(groupKey);
+ assert.ok(group.name === 'Localizable.strings');
+ });
+ });
+
+ describe('createVariantGroup', () => {
+ it('should create a new Test Variant Group', () => {
+ delete project.getPBXObject('PBXVariantGroup');
+
+ var found = false;
+ var groups = project.getPBXObject('PBXVariantGroup');
+
+ var found = findByName(groups, 'Test');
+ assert.ok(found === false);
+
+ var group = project.findPBXVariantGroupKey({name:'Test'});
+ assert.ok(group === undefined);
+
+ project.pbxCreateVariantGroup('Test');
+
+ groups = project.getPBXObject('PBXVariantGroup');
+ found = findByName(groups, 'Test');
+ assert.ok(found === true);
+
+ group = project.findPBXVariantGroupKey({name:'Test'});
+ assert.ok(typeof group === 'string');
+ });
+ });
+
+ describe('findVariantGroupKey', () => {
+ it('should return a valid group key', () => {
+ var keyByName = project.findPBXVariantGroupKey({ name:
'Localizable.strings'});
+ var nonExistingKey = project.findPBXVariantGroupKey({ name:
'Foo'});
+
+ assert.ok(keyByName === '07E3BDBC1DF1DEA500E49912');
+ assert.ok(nonExistingKey === undefined);
+ });
+ });
+
+ describe('createLocalisationVariantGroup', () => {
+ it('should create a new localisation variationgroup then add group to
Resources group', () => {
+ delete project.getPBXObject('PBXVariantGroup');
Review Comment:
## CodeQL / Deleting non-property
Only properties should be deleted.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/177)
##########
test/group.js:
##########
@@ -75,404 +78,379 @@
return found;
}
-exports.setUp = function(callback) {
- project = new pbx('test/parser/projects/group.pbxproj');
- projectHash = project.parseSync();
- callback();
-}
-
-exports.getGroupByKey = {
- 'should return PBXGroup for Classes': function(test) {
- var groupKey = project.findPBXGroupKey({name: 'Classes'});
- var group = project.getPBXGroupByKey(groupKey);
- test.ok(group.name === 'Classes');
- test.done();
- },
- 'should return PBXGroup for Plugins': function(test) {
- var groupKey = project.findPBXGroupKey({name: 'Plugins'});
- var group = project.getPBXGroupByKey(groupKey);
- test.ok(group.name === 'Plugins');
- test.done();
- }
-}
-
-exports.createGroup = {
- 'should create a new Test Group': function(test) {
- var found = false;
- var groups = project.getPBXObject('PBXGroup');
+describe('group', () => {
+ beforeEach(() => {
+ project = new pbx('test/parser/projects/group.pbxproj');
+ projectHash = project.parseSync();
+ });
+
+ describe('getGroupByKey', () => {
+ it('should return PBXGroup for Classes', () => {
+ var groupKey = project.findPBXGroupKey({name: 'Classes'});
+ var group = project.getPBXGroupByKey(groupKey);
+ assert.ok(group.name === 'Classes');
+ });
+
+ it('should return PBXGroup for Plugins', () => {
+ var groupKey = project.findPBXGroupKey({name: 'Plugins'});
+ var group = project.getPBXGroupByKey(groupKey);
+ assert.ok(group.name === 'Plugins');
+ });
+ });
+
+ describe('createGroup', () => {
+ it('should create a new Test Group', () => {
+ var found = false;
+ var groups = project.getPBXObject('PBXGroup');
+
+ var found = findByName(groups, 'Test');
+ assert.ok(found === false);
+
+
+ var group = project.findPBXGroupKey({name:'Test'});
+ assert.ok(group === undefined);
+
+ project.pbxCreateGroup('Test', 'Test');
+
+ groups = project.getPBXObject('PBXGroup');
+ found = findByName(groups, 'Test');
+ assert.ok(found === true);
+
+ group = project.findPBXGroupKey({name:'Test'});
+ assert.ok(typeof group === 'string');
+ });
+ });
+
+ describe('findGroupKey', () => {
+ it('should return a valid group key', () => {
+ var keyByName = project.findPBXGroupKey({ name: 'Classes'});
+ var keyByPath = project.findPBXGroupKey({ path: 'icons'});
+ var keyByPathName = project.findPBXGroupKey({ path:
'"HelloCordova/Plugins"', name: 'Plugins'});
+ var nonExistingKey = project.findPBXGroupKey({ name: 'Foo'});
+
+ assert.ok(keyByName === '080E96DDFE201D6D7F000001');
+ assert.ok(keyByPath === '308D052D1370CCF300D202BF');
+ assert.ok(keyByPathName === '307C750510C5A3420062BCA9');
+ assert.ok(nonExistingKey === undefined);
+
+ });
+ });
+
+ describe('addGroupToGroup', () => {
+ it('should create a new test group then add group to Classes group',
() => {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var classesKey = project.findPBXGroupKey({name: 'Classes'});
+ project.addToPbxGroup(testKey, classesKey);
+
+ var classesGroup = project.getPBXGroupByKey(classesKey);
+ var foundTestGroup = false;
+ for (var i = 0, j = classesGroup.children.length; i < j; i++) {
+ var child = classesGroup.children[i];
+ if (child.value === testKey && child.comment === 'Test') {
+ foundTestGroup = true;
+ }
+ }
- var found = findByName(groups, 'Test');
- test.ok(found === false);
+ assert.ok(foundTestGroup);
+ });
+ });
- var group = project.findPBXGroupKey({name:'Test'});
- test.ok(group === undefined);
+ describe('predefinedPbxGroups', () => {
+ beforeEach(() => {
+ project = new
pbx('test/parser/projects/empty-groups.pbxproj').parseSync();
- project.pbxCreateGroup('Test', 'Test');
+ this.file = new pbxFile('some-file.m');
+ this.file.fileRef = project.generateUuid();
+ project.addToPbxFileReferenceSection(this.file);
+ });
- groups = project.getPBXObject('PBXGroup');
- found = findByName(groups, 'Test');
- test.ok(found === true);
+ it('should add a file to "Plugins" group', () => {
+ project.addToPluginsPbxGroup(this.file);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Plugins'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
- group = project.findPBXGroupKey({name:'Test'});
- test.ok(typeof group === 'string');
- test.done();
- }
-}
+ it('should remove a file from "Plugins" group', () => {
+ project.addToPluginsPbxGroup(this.file);
+ project.removeFromPluginsPbxGroup(this.file);
-exports.findGroupKey = {
- 'should return a valid group key':function(test) {
- var keyByName = project.findPBXGroupKey({ name: 'Classes'});
- var keyByPath = project.findPBXGroupKey({ path: 'icons'});
- var keyByPathName = project.findPBXGroupKey({ path:
'"HelloCordova/Plugins"', name: 'Plugins'});
- var nonExistingKey = project.findPBXGroupKey({ name: 'Foo'});
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Plugins'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
- test.ok(keyByName === '080E96DDFE201D6D7F000001');
- test.ok(keyByPath === '308D052D1370CCF300D202BF');
- test.ok(keyByPathName === '307C750510C5A3420062BCA9');
- test.ok(nonExistingKey === undefined);
+ it('should add a file to "Resources" group', () => {
+ project.addToResourcesPbxGroup(this.file);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
-exports.addGroupToGroup = {
- 'should create a new test group then add group to Classes group':
function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var classesKey = project.findPBXGroupKey({name: 'Classes'});
- project.addToPbxGroup(testKey, classesKey);
-
- var classesGroup = project.getPBXGroupByKey(classesKey);
- var foundTestGroup = false;
- for (var i = 0, j = classesGroup.children.length; i < j; i++) {
- var child = classesGroup.children[i];
- if (child.value === testKey && child.comment === 'Test') {
- foundTestGroup = true;
- }
- }
+ it('should remove a file from "Resources" group', () => {
+ project.addToResourcesPbxGroup(this.file);
+ project.removeFromResourcesPbxGroup(this.file);
- test.ok(foundTestGroup);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
- test.done();
- }
-}
+ it('should add a file to "Frameworks" group', () => {
+ project.addToFrameworksPbxGroup(this.file);
-exports.predefinedPbxGroups = {
- setUp: function(callback) {
- project = new
pbx('test/parser/projects/empty-groups.pbxproj').parseSync();
-
- this.file = new pbxFile('some-file.m');
- this.file.fileRef = project.generateUuid();
- project.addToPbxFileReferenceSection(this.file);
-
- callback();
- },
-
- 'should add a file to "Plugins" group': function(test) {
- project.addToPluginsPbxGroup(this.file);
- var foundInGroup = findChildInGroup(project.pbxGroupByName('Plugins'),
this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Plugins" group': function(test) {
- project.addToPluginsPbxGroup(this.file);
- project.removeFromPluginsPbxGroup(this.file);
-
- var foundInGroup = findChildInGroup(project.pbxGroupByName('Plugins'),
this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- },
-
- 'should add a file to "Resources" group': function(test) {
- project.addToResourcesPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Resources" group': function(test) {
- project.addToResourcesPbxGroup(this.file);
- project.removeFromResourcesPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- },
-
- 'should add a file to "Frameworks" group': function(test) {
- project.addToFrameworksPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Frameworks" group': function(test) {
- project.addToFrameworksPbxGroup(this.file);
- project.removeFromFrameworksPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- },
-
- 'should add a file to "Products" group': function(test) {
- project.addToProductsPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
- test.ok(foundInGroup);
- test.done();
- },
-
- 'should remove a file from "Products" group': function(test) {
- project.addToProductsPbxGroup(this.file);
- project.removeFromProductsPbxGroup(this.file);
-
- var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
- test.ok(!foundInGroup);
- test.done();
- }
-};
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
-exports.addSourceFileToGroup = {
- 'should create group + add source file' : function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addSourceFile('Notifications.m', {}, testKey);
+ it('should remove a file from "Frameworks" group', () => {
+ project.addToFrameworksPbxGroup(this.file);
+ project.removeFromFrameworksPbxGroup(this.file);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
- var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
- test.ok(foundInBuildFileSection);
+ it('should add a file to "Products" group', () => {
+ project.addToProductsPbxGroup(this.file);
- var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
- test.ok(foundInBuildPhase);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
+ assert.ok(foundInGroup);
+ });
- test.done();
- }
-}
+ it('should remove a file from "Products" group', () => {
+ project.addToProductsPbxGroup(this.file);
+ project.removeFromProductsPbxGroup(this.file);
-exports.removeSourceFileFromGroup = {
- 'should create group + add source file then remove source file' :
function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addSourceFile('Notifications.m', {}, testKey);
+ var foundInGroup =
findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef);
+ assert.ok(!foundInGroup);
+ });
+ });
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ describe('addSourceFileToGroup', () => {
+ it('should create group + add source file', () => {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addSourceFile('Notifications.m', {}, testKey);
- var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
- test.ok(foundInBuildFileSection);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
- var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
- test.ok(foundInBuildPhase);
+ var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
+ assert.ok(foundInBuildFileSection);
- project.removeSourceFile('Notifications.m', {}, testKey);
+ var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
+ assert.ok(foundInBuildPhase);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(!foundInGroup);
+ });
+ });
- var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
- test.ok(!foundInBuildFileSection);
+ describe('removeSourceFileFromGroup', () => {
+ it('should create group + add source file then remove source file', ()
=> {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addSourceFile('Notifications.m', {}, testKey);
- var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
- test.ok(!foundInBuildPhase);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
- test.done();
- }
-}
+ var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
+ assert.ok(foundInBuildFileSection);
-exports.addHeaderFileToGroup = {
- 'should create group + add header file' : function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addHeaderFile('Notifications.h', {}, testKey);
+ var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
+ assert.ok(foundInBuildPhase);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ project.removeSourceFile('Notifications.m', {}, testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(!foundInGroup);
-exports.removeHeaderFileFromGroup = {
- 'should create group + add source file then remove header file' :
function(test) {
- var testKey = project.pbxCreateGroup('Test', 'Test');
- var file = project.addHeaderFile('Notifications.h', {}, testKey);
+ var foundInBuildFileSection =
findByFileRef(project.pbxBuildFileSection(), file.fileRef);
+ assert.ok(!foundInBuildFileSection);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ var foundInBuildPhase =
findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid);
+ assert.ok(!foundInBuildPhase);
- project.removeHeaderFile('Notifications.h', {}, testKey);
+ });
+ });
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(!foundInGroup);
+ describe('addHeaderFileToGroup', () => {
+ it('should create group + add header file', () => {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addHeaderFile('Notifications.h', {}, testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
-exports.addResourceFileToGroup = {
- 'should add resource file (PNG) to the splash group' : function(test) {
+ });
+ });
- var testKey = project.findPBXGroupKey({path:'splash'});
- var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
+ describe('removeHeaderFileFromGroup', () => {
+ it('should create group + add source file then remove header file', ()
=> {
+ var testKey = project.pbxCreateGroup('Test', 'Test');
+ var file = project.addHeaderFile('Notifications.h', {}, testKey);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
- test.done();
- }
-}
+ project.removeHeaderFile('Notifications.h', {}, testKey);
-exports.removeResourceFileFromGroup = {
- 'should add resource file (PNG) then remove resource file from splash
group' : function(test) {
- var testKey = project.findPBXGroupKey({path:'splash'});
- var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(!foundInGroup);
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(foundInGroup);
+ });
+ });
- project.removeResourceFile('DefaultTest-667h.png', {}, testKey);
+ describe('addResourceFileToGroup', () => {
+ it('should add resource file (PNG) to the splash group', () => {
- var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
- test.ok(!foundInGroup);
+ var testKey = project.findPBXGroupKey({path:'splash'});
+ var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
-exports.retrieveBuildPropertyForBuild = {
- 'should retrieve valid build property ':function(test) {
- var releaseTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Release');
- var debugTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Debug');
- var nonExistingProperty = project.getBuildProperty('FOO', 'Debug');
- var nonExistingBuild =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Foo');
+ });
+ });
- test.equal(releaseTargetedDeviceFamily, '"1,2"');
- test.equal(debugTargetedDeviceFamily,'"1"');
- test.equal(nonExistingProperty, undefined);
- test.equal(nonExistingBuild, undefined);
+ describe('removeResourceFileFromGroup', () => {
+ it('should add resource file (PNG) then remove resource file from
splash group', () => {
+ var testKey = project.findPBXGroupKey({path:'splash'});
+ var file = project.addResourceFile('DefaultTest-667h.png', {},
testKey);
- test.done();
- }
-}
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(foundInGroup);
-exports.retrieveBuildConfigByName = {
- 'should retrieve valid build config':function(test) {
- var releaseBuildConfig = project.getBuildConfigByName('Release');
- for (var property in releaseBuildConfig) {
- var value = releaseBuildConfig[property];
- test.ok(value.name === 'Release');
- }
+ project.removeResourceFile('DefaultTest-667h.png', {}, testKey);
- var debugBuildConfig = project.getBuildConfigByName('Debug');
- for (var property in debugBuildConfig) {
- var value = debugBuildConfig[property];
- test.ok(value.name === 'Debug');
- }
+ var foundInGroup =
findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef );
+ assert.ok(!foundInGroup);
- var nonExistingBuildConfig = project.getBuildConfigByName('Foo');
- test.deepEqual(nonExistingBuildConfig, {});
+ });
+ });
- test.done();
- }
-}
+ describe('retrieveBuildPropertyForBuild', () => {
+ it('should retrieve valid build property ', () => {
+ var releaseTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Release');
+ var debugTargetedDeviceFamily =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Debug');
+ var nonExistingProperty = project.getBuildProperty('FOO', 'Debug');
+ var nonExistingBuild =
project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Foo');
-/* This proves the issue in 0.6.7
-exports.validatePropReplaceException = {
- 'should throw TypeError for updateBuildProperty VALID_ARCHS when none
existed' : function(test) {
- test.throws(
- function() {
- project.updateBuildProperty('VALID_ARCHS', '"armv7 armv7s');
- },
- TypeError,
- "Object object has no method 'hasOwnProperty'"
- );
- test.done();
- }
-}
-*/
+ assert.equal(releaseTargetedDeviceFamily, '"1,2"');
+ assert.equal(debugTargetedDeviceFamily,'"1"');
+ assert.equal(nonExistingProperty, undefined);
+ assert.equal(nonExistingBuild, undefined);
-exports.validatePropReplaceFix = {
- 'should create build configuration for VALID_ARCHS when none existed' :
function(test) {
- project.updateBuildProperty('VALID_ARCHS', '"armv7 armv7s"', 'Debug');
- test.done();
- }
-}
+ });
+ });
-exports.validateHasFile = {
- 'should return true for has file MainViewController.m': function(test) {
- var result = project.hasFile('MainViewController.m');
- test.ok(result.path == "MainViewController.m");
- test.done();
- }
-}
+ describe('retrieveBuildConfigByName', () => {
+ it('should retrieve valid build config', () => {
+ var releaseBuildConfig = project.getBuildConfigByName('Release');
+ for (var property in releaseBuildConfig) {
+ var value = releaseBuildConfig[property];
+ assert.ok(value.name === 'Release');
+ }
-exports.testWritingPBXProject = {
- 'should successfully write to PBXProject TargetAttributes': function(test)
{
- var pbxProjectObj = project.getPBXObject('PBXProject');
- var pbxProject;
- for (var property in pbxProjectObj) {
- if (!/comment/.test(property)) {
- pbxProject = pbxProjectObj[property];
+ var debugBuildConfig = project.getBuildConfigByName('Debug');
+ for (var property in debugBuildConfig) {
+ var value = debugBuildConfig[property];
+ assert.ok(value.name === 'Debug');
}
- }
- var target;
- var projectTargets = pbxProject.targets;
- for (var i = 0, j = pbxProject.targets.length; i < j; i++ ) {
- target = pbxProject.targets[i].value;
- }
+ var nonExistingBuildConfig = project.getBuildConfigByName('Foo');
+ assert.deepEqual(nonExistingBuildConfig, {});
- pbxProject.attributes.TargetAttributes = {};
- pbxProject.attributes.TargetAttributes[target] = {
- DevelopmentTeam: 'N6X4RJZZ5D',
- SystemCapabilities: {
- "com.apple.BackgroundModes": {
- enabled : 0
- },
- "com.apple.DataProtection" : {
- enabled : 0
+ });
+ });
+
+ /* This proves the issue in 0.6.7
+ describe('validatePropReplaceException', () => {
+ it('should throw TypeError for updateBuildProperty VALID_ARCHS when
none existed', () => {
+ assert.throws(
+ function() {
+ project.updateBuildProperty('VALID_ARCHS', '"armv7
armv7s');
},
- "com.apple.Keychain" : {
- enabled: 1
+ TypeError,
+ "Object object has no method 'hasOwnProperty'"
+ );
+ });
+ }
+ */
+
+ describe('validatePropReplaceFix', () => {
+ it('should create build configuration for VALID_ARCHS when none
existed', () => {
+ project.updateBuildProperty('VALID_ARCHS', '"armv7 armv7s"',
'Debug');
+ });
+ });
+
+ describe('validateHasFile', () => {
+ it('should return true for has file MainViewController.m', () => {
+ var result = project.hasFile('MainViewController.m');
+ assert.ok(result.path == "MainViewController.m");
+ });
+ });
+
+ describe('testWritingPBXProject', () => {
+ it('should successfully write to PBXProject TargetAttributes', () => {
+ var pbxProjectObj = project.getPBXObject('PBXProject');
+ var pbxProject;
+ for (var property in pbxProjectObj) {
+ if (!/comment/.test(property)) {
+ pbxProject = pbxProjectObj[property];
}
}
- };
-
- var output = project.writeSync();
-
- test.done();
- },
- 'should add target attribute to PBXProject TargetAttributes':
function(test) {
- project.addTargetAttribute('ProvisioningStyle', 'Manual');
- var output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
-
- test.done();
- },
- 'should change target attribute at PBXProject TargetAttributes':
function(test) {
- project.addTargetAttribute('ProvisioningStyle', 'Manual');
- var output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
-
- project.addTargetAttribute('ProvisioningStyle', 'Automatic');
- output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
- test.equal(output.match(/ProvisioningStyle\s*=\s*Automatic/g).length,
1);
-
- test.done();
- },
- 'should remove target attribute from PBXProject TargetAttributes':
function(test) {
- project.addTargetAttribute('ProvisioningStyle', 'Manual');
- var output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
-
- project.removeTargetAttribute('ProvisioningStyle');
- output = project.writeSync();
- test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
-
- test.done();
- }
-}
+
+ var target;
+ var projectTargets = pbxProject.targets;
Review Comment:
## CodeQL / Unused variable, import, function or class
Unused variable projectTargets.
[Show more
details](https://github.com/apache/cordova-node-xcode/security/code-scanning/189)
--
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]