@@ -177,6 +177,90 @@ exports['updateBuildProperty function'] = {
177177 }
178178}
179179
180+ exports [ 'addBuildProperty function' ] = {
181+ setUp :function ( callback ) {
182+ callback ( ) ;
183+ } ,
184+ tearDown :function ( callback ) {
185+ fs . writeFileSync ( bcpbx , original_pbx , 'utf-8' ) ;
186+ callback ( ) ;
187+ } ,
188+ 'should add 4 build properties in the .pbxproj file' : function ( test ) {
189+ var myProj = new pbx ( 'test/parser/projects/build-config.pbxproj' ) ;
190+ myProj . parse ( function ( err , hash ) {
191+ myProj . addBuildProperty ( 'ENABLE_BITCODE' , 'NO' ) ;
192+ var newContents = myProj . writeSync ( ) ;
193+ test . equal ( newContents . match ( / E N A B L E _ B I T C O D E \s * = \s * N O / g) . length , 4 ) ;
194+ test . done ( ) ;
195+ } ) ;
196+ } ,
197+ 'should add 2 build properties in the .pbxproj file for specific build' : function ( test ) {
198+ var myProj = new pbx ( 'test/parser/projects/build-config.pbxproj' ) ;
199+ myProj . parse ( function ( err , hash ) {
200+ myProj . addBuildProperty ( 'ENABLE_BITCODE' , 'NO' , 'Release' ) ;
201+ var newContents = myProj . writeSync ( ) ;
202+ test . equal ( newContents . match ( / E N A B L E _ B I T C O D E \s * = \s * N O / g) . length , 2 ) ;
203+ test . done ( ) ;
204+ } ) ;
205+ } ,
206+ 'should not add build properties in the .pbxproj file for nonexist build' : function ( test ) {
207+ var myProj = new pbx ( 'test/parser/projects/build-config.pbxproj' ) ;
208+ myProj . parse ( function ( err , hash ) {
209+ myProj . addBuildProperty ( 'ENABLE_BITCODE' , 'NO' , 'nonexist' ) ;
210+ var newContents = myProj . writeSync ( ) ;
211+ test . ok ( ! newContents . match ( / E N A B L E _ B I T C O D E \s * = \s * N O / g) ) ;
212+ test . done ( ) ;
213+ } ) ;
214+ }
215+ }
216+
217+ exports [ 'removeBuildProperty function' ] = {
218+ setUp :function ( callback ) {
219+ callback ( ) ;
220+ } ,
221+ tearDown :function ( callback ) {
222+ fs . writeFileSync ( bcpbx , original_pbx , 'utf-8' ) ;
223+ callback ( ) ;
224+ } ,
225+ 'should remove all build properties in the .pbxproj file' : function ( test ) {
226+ var myProj = new pbx ( 'test/parser/projects/build-config.pbxproj' ) ;
227+ myProj . parse ( function ( err , hash ) {
228+ myProj . removeBuildProperty ( 'IPHONEOS_DEPLOYMENT_TARGET' ) ;
229+ var newContents = myProj . writeSync ( ) ;
230+ test . ok ( ! newContents . match ( / I P H O N E O S _ D E P L O Y M E N T _ T A R G E T / ) ) ;
231+ test . done ( ) ;
232+ } ) ;
233+ } ,
234+ 'should remove specific build properties in the .pbxproj file' : function ( test ) {
235+ var myProj = new pbx ( 'test/parser/projects/build-config.pbxproj' ) ;
236+ myProj . parse ( function ( err , hash ) {
237+ myProj . removeBuildProperty ( 'IPHONEOS_DEPLOYMENT_TARGET' , 'Debug' ) ;
238+ var newContents = myProj . writeSync ( ) ;
239+ test . equal ( newContents . match ( / I P H O N E O S _ D E P L O Y M E N T _ T A R G E T / g) . length , 2 ) ;
240+ test . done ( ) ;
241+ } ) ;
242+ } ,
243+ 'should not remove any build properties in the .pbxproj file' : function ( test ) {
244+ var myProj = new pbx ( 'test/parser/projects/build-config.pbxproj' ) ;
245+ myProj . parse ( function ( err , hash ) {
246+ myProj . removeBuildProperty ( 'IPHONEOS_DEPLOYMENT_TARGET' , 'notexist' ) ;
247+ var newContents = myProj . writeSync ( ) ;
248+ test . equal ( newContents . match ( / I P H O N E O S _ D E P L O Y M E N T _ T A R G E T / g) . length , 4 ) ;
249+ test . done ( ) ;
250+ } ) ;
251+ } ,
252+ 'should fine with remove inexist build properties in the .pbxproj file' : function ( test ) {
253+ var myProj = new pbx ( 'test/parser/projects/build-config.pbxproj' ) ;
254+ myProj . parse ( function ( err , hash ) {
255+ myProj . removeBuildProperty ( 'ENABLE_BITCODE' ) ;
256+ var newContents = myProj . writeSync ( ) ;
257+ test . ok ( ! newContents . match ( / E N A B L E _ B I T C O D E / ) ) ;
258+ test . done ( ) ;
259+ } ) ;
260+ }
261+
262+ }
263+
180264exports [ 'productName field' ] = {
181265 'should return the product name' : function ( test ) {
182266 var newProj = new pbx ( '.' ) ;
0 commit comments