Skip to content

Commit

Permalink
Test coverage for app_extension target types (#66)
Browse files Browse the repository at this point in the history
* tests for app_extension build phase additions

* coverage for pbxCopyFilesBuildPhaseObj func

Co-authored-by: Ross Bender <[email protected]>
Co-Authored-By: Chris Brody <[email protected]>
  • Loading branch information
3 people committed Oct 17, 2019
1 parent 122994d commit 0d3304c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/addBuildPhase.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,61 @@ exports.addBuildPhase = {
test.deepEqual(initialFileReferenceSectionItemsCount.length, afterAdditionBuildFileSectionItemsCount.length - 2);
test.done();
},
'should set target to Wrapper given \'application\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'application').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 1);
test.done();
},
'should set target to Plugins given \'app_extension\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'app_extension').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 13);
test.done();
},
'should set target to Wapper given \'bundle\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'bundle').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 1);
test.done();
},
'should set target to Wapper given \'command_line_tool\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'command_line_tool').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 1);
test.done();
},
'should set target to Products Directory given \'dynamic_library\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'dynamic_library').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 16);
test.done();
},
'should set target to Shared Framework given \'framework\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'framework').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 11);
test.done();
},
'should set target to Frameworks given \'frameworks\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'frameworks').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 10);
test.done();
},
'should set target to Products Directory given \'static_library\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'static_library').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 16);
test.done();
},
'should set target to Wrapper given \'unit_test_bundle\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'unit_test_bundle').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 1);
test.done();
},
'should set target to Wrapper given \'watch_app\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'watch_app').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 1);
test.done();
},
'should set target to Plugins given \'watch_extension\' as target': function (test) {
var buildPhase = proj.addBuildPhase(['file.m'], 'PBXCopyFilesBuildPhase', 'Copy Files', proj.getFirstTarget().uuid, 'watch_extension').buildPhase;
test.equal(buildPhase.dstSubfolderSpec, 13);
test.done();
},
'should add a script build phase to echo "hello world!"': function(test) {
var options = {shellPath: '/bin/sh', shellScript: 'echo "hello world!"'};
var buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase;
Expand Down
20 changes: 20 additions & 0 deletions test/addTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ exports.addTarget = {
test.ok(target.pbxNativeTarget.buildRules);
test.ok(target.pbxNativeTarget.dependencies);

test.done();
},
'should add build phase for extension target': function (test) {
var target = proj.addTarget(TARGET_NAME, TARGET_TYPE);
test.ok(target.uuid);

var phases = proj.pbxCopyfilesBuildPhaseObj(target.uuid);
test.ok(phases);
test.ok(phases.files);
test.equal(phases.files.length, 1);

test.done();
},
'should not add build phase for non-extension target': function (test) {
var target = proj.addTarget(TARGET_NAME, 'application');
test.ok(target.uuid);

var phases = proj.pbxCopyfilesBuildPhaseObj(target.uuid);
test.ok(!phases);

test.done();
}
}

0 comments on commit 0d3304c

Please sign in to comment.