Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage for app_extension target types #66

Merged
merged 5 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 22 additions & 1 deletion test/addTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
var fullProject = require('./fixtures/full-project')
fullProjectStr = JSON.stringify(fullProject),
pbx = require('../lib/pbxProject'),
pbxFile = require('../lib/pbxFile'),
l3ender marked this conversation as resolved.
Show resolved Hide resolved
proj = new pbx('.');

function cleanHash() {
Expand Down Expand Up @@ -101,5 +102,25 @@ exports.addTarget = {
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();
},
l3ender marked this conversation as resolved.
Show resolved Hide resolved
}