@@ -328,3 +328,103 @@ exports['hasFile'] = {
328328 test . done ( )
329329 }
330330}
331+
332+ exports [ 'addToPbxFileReferenceSection' ] = {
333+ 'should not quote name when no special characters present in basename' : function ( test ) {
334+ var newProj = new pbx ( '.' ) ;
335+ newProj . hash = jsonProject ,
336+ file = {
337+ uuid : newProj . generateUuid ( ) ,
338+ fileRef : newProj . generateUuid ( ) ,
339+ isa : 'PBXFileReference' ,
340+ explicitFileType : 'wrapper.application' ,
341+ includeInIndex : 0 ,
342+ basename : "SomeFile.m" ,
343+ path : "SomePath.m" ,
344+ sourceTree : 'BUILT_PRODUCTS_DIR'
345+ } ,
346+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
347+
348+ newProj . addToPbxFileReferenceSection ( file ) ;
349+ test . equal ( fileRefSection [ file . fileRef ] . name , "SomeFile.m" ) ;
350+ test . done ( ) ;
351+ } ,
352+ 'should quote name when special characters present in basename' : function ( test ) {
353+ var newProj = new pbx ( '.' ) ;
354+ newProj . hash = jsonProject ,
355+ file = {
356+ uuid : newProj . generateUuid ( ) ,
357+ fileRef : newProj . generateUuid ( ) ,
358+ isa : 'PBXFileReference' ,
359+ explicitFileType : 'wrapper.application' ,
360+ includeInIndex : 0 ,
361+ basename : "Some File.m" ,
362+ path : "SomePath.m" ,
363+ sourceTree : 'BUILT_PRODUCTS_DIR'
364+ } ,
365+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
366+
367+ newProj . addToPbxFileReferenceSection ( file ) ;
368+ test . equal ( fileRefSection [ file . fileRef ] . name , '"Some File.m"' ) ;
369+ test . done ( ) ;
370+ } ,
371+ 'should not quote path when no special characters present in path' : function ( test ) {
372+ var newProj = new pbx ( '.' ) ;
373+ newProj . hash = jsonProject ,
374+ file = {
375+ uuid : newProj . generateUuid ( ) ,
376+ fileRef : newProj . generateUuid ( ) ,
377+ isa : 'PBXFileReference' ,
378+ explicitFileType : 'wrapper.application' ,
379+ includeInIndex : 0 ,
380+ basename : "SomeFile.m" ,
381+ path : "SomePath.m" ,
382+ sourceTree : 'BUILT_PRODUCTS_DIR'
383+ } ,
384+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
385+
386+ newProj . addToPbxFileReferenceSection ( file ) ;
387+ test . equal ( fileRefSection [ file . fileRef ] . path , "SomePath.m" ) ;
388+ test . done ( ) ;
389+ } ,
390+ 'should quote path when special characters present in path' : function ( test ) {
391+ var newProj = new pbx ( '.' ) ;
392+ newProj . hash = jsonProject ,
393+ file = {
394+ uuid : newProj . generateUuid ( ) ,
395+ fileRef : newProj . generateUuid ( ) ,
396+ isa : 'PBXFileReference' ,
397+ explicitFileType : 'wrapper.application' ,
398+ includeInIndex : 0 ,
399+ basename : "SomeFile.m" ,
400+ path : "SomeFolder/Some Path.m" ,
401+ sourceTree : 'BUILT_PRODUCTS_DIR'
402+ } ,
403+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
404+
405+ newProj . addToPbxFileReferenceSection ( file ) ;
406+ test . equal ( fileRefSection [ file . fileRef ] . path , '"SomeFolder/Some Path.m"' ) ;
407+ test . done ( ) ;
408+ } ,
409+ 'should quote path and name when special characters present in path and basename' : function ( test ) {
410+ var newProj = new pbx ( '.' ) ;
411+ newProj . hash = jsonProject ,
412+ file = {
413+ uuid : newProj . generateUuid ( ) ,
414+ fileRef : newProj . generateUuid ( ) ,
415+ isa : 'PBXFileReference' ,
416+ explicitFileType : 'wrapper.application' ,
417+ includeInIndex : 0 ,
418+ basename : "Some File.m" ,
419+ path : "SomeFolder/Some Path.m" ,
420+ sourceTree : 'BUILT_PRODUCTS_DIR'
421+ } ,
422+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
423+
424+ newProj . addToPbxFileReferenceSection ( file ) ;
425+ test . equal ( fileRefSection [ file . fileRef ] . name , '"Some File.m"' ) ;
426+ test . equal ( fileRefSection [ file . fileRef ] . path , '"SomeFolder/Some Path.m"' ) ;
427+ test . done ( ) ;
428+ }
429+ }
430+
0 commit comments