|
| 1 | +var fullProject = require('./fixtures/full-project') |
| 2 | + fullProjectStr = JSON.stringify(fullProject), |
| 3 | + pbx = require('../lib/pbxProject'), |
| 4 | + proj = new pbx('.'); |
| 5 | + |
| 6 | +function cleanHash() { |
| 7 | + return JSON.parse(fullProjectStr); |
| 8 | +} |
| 9 | + |
| 10 | +exports.setUp = function (callback) { |
| 11 | + proj.hash = cleanHash(); |
| 12 | + callback(); |
| 13 | +} |
| 14 | + |
| 15 | +exports.addTargetDependency = { |
| 16 | + 'should return undefined when no target specified': function (test) { |
| 17 | + var buildPhase = proj.addTargetDependency(); |
| 18 | + |
| 19 | + test.ok(typeof buildPhase === 'undefined'); |
| 20 | + test.done() |
| 21 | + }, |
| 22 | + 'should throw when target not found in nativeTargetsSection': function (test) { |
| 23 | + test.throws(function() { |
| 24 | + proj.addTargetDependency('invalidTarget'); |
| 25 | + }); |
| 26 | + test.done() |
| 27 | + }, |
| 28 | + 'should throw when any dependency target not found in nativeTargetsSection': function (test) { |
| 29 | + test.throws(function() { |
| 30 | + proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['invalidTarget']); |
| 31 | + }); |
| 32 | + test.done() |
| 33 | + }, |
| 34 | + 'should return the pbxTarget': function (test) { |
| 35 | + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54']); |
| 36 | + |
| 37 | + test.ok(typeof target == 'object'); |
| 38 | + test.ok(target.uuid); |
| 39 | + test.ok(target.target); |
| 40 | + test.done(); |
| 41 | + }, |
| 42 | + 'should add targetDependencies to target': function (test) { |
| 43 | + var targetInPbxProj = proj.pbxNativeTarget()['1D6058900D05DD3D006BFB55']; |
| 44 | + test.deepEqual(targetInPbxProj.dependencies, []); |
| 45 | + |
| 46 | + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; |
| 47 | + test.deepEqual(targetInPbxProj.dependencies, target.dependencies) |
| 48 | + test.done() |
| 49 | + }, |
| 50 | + 'should create a PBXTargetDependency for each dependency target': function (test) { |
| 51 | + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], |
| 52 | + target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; |
| 53 | + |
| 54 | + for (var index = 0; index < target.dependencies.length; index++) { |
| 55 | + var dependency = target.dependencies[index].value; |
| 56 | + test.ok(pbxTargetDependencySection[dependency]); |
| 57 | + } |
| 58 | + |
| 59 | + test.done() |
| 60 | + }, |
| 61 | + 'should set right comment for each dependency target': function (test) { |
| 62 | + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], |
| 63 | + target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; |
| 64 | + |
| 65 | + for (var index = 0; index < target.dependencies.length; index++) { |
| 66 | + var dependencyCommentKey = target.dependencies[index].value + '_comment'; |
| 67 | + test.equal(pbxTargetDependencySection[dependencyCommentKey], 'PBXTargetDependency'); |
| 68 | + } |
| 69 | + |
| 70 | + test.done() |
| 71 | + }, |
| 72 | + 'should create a PBXContainerItemProxy for each PBXTargetDependency': function (test) { |
| 73 | + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], |
| 74 | + pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], |
| 75 | + target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; |
| 76 | + |
| 77 | + for (var index = 0; index < target.dependencies.length; index++) { |
| 78 | + var dependency = target.dependencies[index].value, |
| 79 | + targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; |
| 80 | + |
| 81 | + test.ok(pbxContainerItemProxySection[targetProxy]); |
| 82 | + } |
| 83 | + |
| 84 | + test.done() |
| 85 | + }, |
| 86 | + 'should set each PBXContainerItemProxy`s remoteGlobalIDString correctly': function (test) { |
| 87 | + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], |
| 88 | + pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], |
| 89 | + target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target, |
| 90 | + remoteGlobalIDStrings = []; |
| 91 | + |
| 92 | + for (var index = 0; index < target.dependencies.length; index++) { |
| 93 | + var dependency = target.dependencies[index].value, |
| 94 | + targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; |
| 95 | + |
| 96 | + remoteGlobalIDStrings.push(pbxContainerItemProxySection[targetProxy]['remoteGlobalIDString']); |
| 97 | + } |
| 98 | + |
| 99 | + test.deepEqual(remoteGlobalIDStrings, ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']); |
| 100 | + test.done() |
| 101 | + }, |
| 102 | + 'should set each PBXContainerItemProxy`s remoteInfo correctly': function (test) { |
| 103 | + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], |
| 104 | + pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], |
| 105 | + target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target, |
| 106 | + remoteInfoArray = []; |
| 107 | + |
| 108 | + for (var index = 0; index < target.dependencies.length; index++) { |
| 109 | + var dependency = target.dependencies[index].value, |
| 110 | + targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; |
| 111 | + |
| 112 | + remoteInfoArray.push(pbxContainerItemProxySection[targetProxy]['remoteInfo']); |
| 113 | + } |
| 114 | + |
| 115 | + test.deepEqual(remoteInfoArray, ['"KitchenSinktablet"', '"TestApp"']); |
| 116 | + test.done() |
| 117 | + }, |
| 118 | + 'should set each PBXContainerItemProxy`s containerPortal correctly': function (test) { |
| 119 | + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], |
| 120 | + pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], |
| 121 | + target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; |
| 122 | + |
| 123 | + for (var index = 0; index < target.dependencies.length; index++) { |
| 124 | + var dependency = target.dependencies[index].value, |
| 125 | + targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; |
| 126 | + |
| 127 | + test.equal(pbxContainerItemProxySection[targetProxy]['containerPortal'], proj.hash.project['rootObject']); |
| 128 | + } |
| 129 | + |
| 130 | + test.done() |
| 131 | + }, |
| 132 | + 'should set each PBXContainerItemProxy`s proxyType correctly': function (test) { |
| 133 | + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], |
| 134 | + pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], |
| 135 | + target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; |
| 136 | + |
| 137 | + for (var index = 0; index < target.dependencies.length; index++) { |
| 138 | + var dependency = target.dependencies[index].value, |
| 139 | + targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; |
| 140 | + |
| 141 | + test.equal(pbxContainerItemProxySection[targetProxy]['proxyType'], 1); |
| 142 | + } |
| 143 | + |
| 144 | + test.done() |
| 145 | + } |
| 146 | +} |
0 commit comments