@@ -39,12 +39,16 @@ exports.addTargetDependency = {
3939 'should throw when target not found in nativeTargetsSection' : function ( test ) {
4040 test . throws ( function ( ) {
4141 proj . addTargetDependency ( 'invalidTarget' ) ;
42+ } , function ( error ) {
43+ return ( error instanceof Error ) && / I n v a l i d t a r g e t / i. test ( error ) ;
4244 } ) ;
4345 test . done ( )
4446 } ,
4547 'should throw when any dependency target not found in nativeTargetsSection' : function ( test ) {
4648 test . throws ( function ( ) {
4749 proj . addTargetDependency ( '1D6058900D05DD3D006BFB54' , [ 'invalidTarget' ] ) ;
50+ } , function ( error ) {
51+ return ( error instanceof Error ) && / I n v a l i d t a r g e t / i. test ( error ) ;
4852 } ) ;
4953 test . done ( )
5054 } ,
@@ -64,6 +68,28 @@ exports.addTargetDependency = {
6468 test . deepEqual ( targetInPbxProj . dependencies , target . dependencies )
6569 test . done ( )
6670 } ,
71+ 'should not modify native target dependencies if PBXTargetDependency object does not exist' : function ( test ) {
72+ delete proj . hash . project . objects [ 'PBXTargetDependency' ] ;
73+
74+ var numDependenciesBefore = proj . pbxNativeTargetSection ( ) [ '1D6058900D05DD3D006BFB54' ] . dependencies . length ;
75+ proj . addTargetDependency ( '1D6058900D05DD3D006BFB54' , [ '1D6058900D05DD3D006BFB54' ] ) ;
76+ var numDependenciesAfter = proj . pbxNativeTargetSection ( ) [ '1D6058900D05DD3D006BFB54' ] . dependencies . length ;
77+
78+ test . equal ( numDependenciesBefore , numDependenciesAfter ) ;
79+
80+ test . done ( ) ;
81+ } ,
82+ 'should not modify native target dependencies if PBXContainerItemProxy object does not exist' : function ( test ) {
83+ delete proj . hash . project . objects [ 'PBXContainerItemProxy' ] ;
84+
85+ var numDependenciesBefore = proj . pbxNativeTargetSection ( ) [ '1D6058900D05DD3D006BFB54' ] . dependencies . length ;
86+ proj . addTargetDependency ( '1D6058900D05DD3D006BFB54' , [ '1D6058900D05DD3D006BFB54' ] ) ;
87+ var numDependenciesAfter = proj . pbxNativeTargetSection ( ) [ '1D6058900D05DD3D006BFB54' ] . dependencies . length ;
88+
89+ test . equal ( numDependenciesBefore , numDependenciesAfter ) ;
90+
91+ test . done ( ) ;
92+ } ,
6793 'should create a PBXTargetDependency for each dependency target' : function ( test ) {
6894 var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
6995 target = proj . addTargetDependency ( '1D6058900D05DD3D006BFB54' , [ '1D6058900D05DD3D006BFB54' , '1D6058900D05DD3D006BFB55' ] ) . target ;
@@ -75,7 +101,7 @@ exports.addTargetDependency = {
75101
76102 test . done ( )
77103 } ,
78- 'should set right comment for each dependency target' : function ( test ) {
104+ 'should set right comment for each target dependency ' : function ( test ) {
79105 var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
80106 target = proj . addTargetDependency ( '1D6058900D05DD3D006BFB54' , [ '1D6058900D05DD3D006BFB54' , '1D6058900D05DD3D006BFB55' ] ) . target ;
81107
@@ -86,6 +112,22 @@ exports.addTargetDependency = {
86112
87113 test . done ( )
88114 } ,
115+ 'should set right comment for each dependency target' : function ( test ) {
116+ var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
117+ target = proj . addTargetDependency ( '1D6058900D05DD3D006BFB54' , [ '1D6058900D05DD3D006BFB54' , '1D6058900D05DD3D006BFB55' ] ) . target ;
118+
119+ for ( var index = 0 ; index < target . dependencies . length ; index ++ ) {
120+ var dependencyTargetUuid = target . dependencies [ index ] . value ;
121+ var targetDependencyUuid = pbxTargetDependencySection [ dependencyTargetUuid ] . target ;
122+
123+ if ( pbxTargetDependencySection [ dependencyTargetUuid ] . target ) {
124+ var targetCommentKey = targetDependencyUuid + '_comment' ;
125+ test . equal ( pbxTargetDependencySection [ dependencyTargetUuid ] . target_comment , proj . pbxNativeTargetSection ( ) [ targetCommentKey ] ) ;
126+ }
127+ }
128+
129+ test . done ( ) ;
130+ } ,
89131 'should create a PBXContainerItemProxy for each PBXTargetDependency' : function ( test ) {
90132 var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
91133 pbxContainerItemProxySection = proj . hash . project . objects [ 'PBXContainerItemProxy' ] ,
@@ -100,6 +142,26 @@ exports.addTargetDependency = {
100142
101143 test . done ( )
102144 } ,
145+ 'should set right comment for each container item proxy' : function ( test ) {
146+ var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
147+ pbxContainerItemProxySection = proj . hash . project . objects [ 'PBXContainerItemProxy' ] ,
148+ target = proj . addTargetDependency ( '1D6058900D05DD3D006BFB54' , [ '1D6058900D05DD3D006BFB54' , '1D6058900D05DD3D006BFB55' ] ) . target ;
149+
150+ for ( var index = 0 ; index < target . dependencies . length ; index ++ ) {
151+ var dependencyTargetUuid = target . dependencies [ index ] . value ;
152+
153+ var proxyUuid = pbxTargetDependencySection [ dependencyTargetUuid ] . targetProxy ;
154+
155+ if ( proxyUuid ) {
156+ test . ok ( pbxTargetDependencySection [ dependencyTargetUuid ] . targetProxy_comment , 'PBXContainerItemProxy' ) ;
157+ test . ok ( pbxContainerItemProxySection [ proxyUuid ] ) ;
158+ var proxyCommentKey = proxyUuid + '_comment' ;
159+ test . ok ( pbxContainerItemProxySection [ proxyCommentKey ] ) ;
160+ }
161+ }
162+
163+ test . done ( ) ;
164+ } ,
103165 'should set each PBXContainerItemProxy`s remoteGlobalIDString correctly' : function ( test ) {
104166 var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
105167 pbxContainerItemProxySection = proj . hash . project . objects [ 'PBXContainerItemProxy' ] ,
@@ -146,6 +208,20 @@ exports.addTargetDependency = {
146208
147209 test . done ( )
148210 } ,
211+ 'should set each PBXContainerItemProxy`s containerPortal_comment correctly' : function ( test ) {
212+ var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
213+ pbxContainerItemProxySection = proj . hash . project . objects [ 'PBXContainerItemProxy' ] ,
214+ target = proj . addTargetDependency ( '1D6058900D05DD3D006BFB55' , [ '1D6058900D05DD3D006BFB54' , '1D6058900D05DD3D006BFB55' ] ) . target ;
215+
216+ for ( var index = 0 ; index < target . dependencies . length ; index ++ ) {
217+ var dependency = target . dependencies [ index ] . value ,
218+ targetProxy = pbxTargetDependencySection [ dependency ] [ 'targetProxy' ] ;
219+
220+ test . equal ( pbxContainerItemProxySection [ targetProxy ] [ 'containerPortal_comment' ] , proj . hash . project [ 'rootObject_comment' ] ) ;
221+ }
222+
223+ test . done ( )
224+ } ,
149225 'should set each PBXContainerItemProxy`s proxyType correctly' : function ( test ) {
150226 var pbxTargetDependencySection = proj . hash . project . objects [ 'PBXTargetDependency' ] ,
151227 pbxContainerItemProxySection = proj . hash . project . objects [ 'PBXContainerItemProxy' ] ,
0 commit comments