@@ -202,3 +202,103 @@ exports['hasFile'] = {
202
202
test . done ( )
203
203
}
204
204
}
205
+
206
+ exports [ 'addToPbxFileReferenceSection' ] = {
207
+ 'should not quote name when no special characters present in basename' : function ( test ) {
208
+ var newProj = new pbx ( '.' ) ;
209
+ newProj . hash = jsonProject ,
210
+ file = {
211
+ uuid : newProj . generateUuid ( ) ,
212
+ fileRef : newProj . generateUuid ( ) ,
213
+ isa : 'PBXFileReference' ,
214
+ explicitFileType : 'wrapper.application' ,
215
+ includeInIndex : 0 ,
216
+ basename : "SomeFile.m" ,
217
+ path : "SomePath.m" ,
218
+ sourceTree : 'BUILT_PRODUCTS_DIR'
219
+ } ,
220
+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
221
+
222
+ newProj . addToPbxFileReferenceSection ( file ) ;
223
+ test . equal ( fileRefSection [ file . fileRef ] . name , "SomeFile.m" ) ;
224
+ test . done ( ) ;
225
+ } ,
226
+ 'should quote name when special characters present in basename' : function ( test ) {
227
+ var newProj = new pbx ( '.' ) ;
228
+ newProj . hash = jsonProject ,
229
+ file = {
230
+ uuid : newProj . generateUuid ( ) ,
231
+ fileRef : newProj . generateUuid ( ) ,
232
+ isa : 'PBXFileReference' ,
233
+ explicitFileType : 'wrapper.application' ,
234
+ includeInIndex : 0 ,
235
+ basename : "Some File.m" ,
236
+ path : "SomePath.m" ,
237
+ sourceTree : 'BUILT_PRODUCTS_DIR'
238
+ } ,
239
+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
240
+
241
+ newProj . addToPbxFileReferenceSection ( file ) ;
242
+ test . equal ( fileRefSection [ file . fileRef ] . name , '"Some File.m"' ) ;
243
+ test . done ( ) ;
244
+ } ,
245
+ 'should not quote path when no special characters present in path' : function ( test ) {
246
+ var newProj = new pbx ( '.' ) ;
247
+ newProj . hash = jsonProject ,
248
+ file = {
249
+ uuid : newProj . generateUuid ( ) ,
250
+ fileRef : newProj . generateUuid ( ) ,
251
+ isa : 'PBXFileReference' ,
252
+ explicitFileType : 'wrapper.application' ,
253
+ includeInIndex : 0 ,
254
+ basename : "SomeFile.m" ,
255
+ path : "SomePath.m" ,
256
+ sourceTree : 'BUILT_PRODUCTS_DIR'
257
+ } ,
258
+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
259
+
260
+ newProj . addToPbxFileReferenceSection ( file ) ;
261
+ test . equal ( fileRefSection [ file . fileRef ] . path , "SomePath.m" ) ;
262
+ test . done ( ) ;
263
+ } ,
264
+ 'should quote path when special characters present in path' : function ( test ) {
265
+ var newProj = new pbx ( '.' ) ;
266
+ newProj . hash = jsonProject ,
267
+ file = {
268
+ uuid : newProj . generateUuid ( ) ,
269
+ fileRef : newProj . generateUuid ( ) ,
270
+ isa : 'PBXFileReference' ,
271
+ explicitFileType : 'wrapper.application' ,
272
+ includeInIndex : 0 ,
273
+ basename : "SomeFile.m" ,
274
+ path : "SomeFolder/Some Path.m" ,
275
+ sourceTree : 'BUILT_PRODUCTS_DIR'
276
+ } ,
277
+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
278
+
279
+ newProj . addToPbxFileReferenceSection ( file ) ;
280
+ test . equal ( fileRefSection [ file . fileRef ] . path , '"SomeFolder/Some Path.m"' ) ;
281
+ test . done ( ) ;
282
+ } ,
283
+ 'should quote path and name when special characters present in path and basename' : function ( test ) {
284
+ var newProj = new pbx ( '.' ) ;
285
+ newProj . hash = jsonProject ,
286
+ file = {
287
+ uuid : newProj . generateUuid ( ) ,
288
+ fileRef : newProj . generateUuid ( ) ,
289
+ isa : 'PBXFileReference' ,
290
+ explicitFileType : 'wrapper.application' ,
291
+ includeInIndex : 0 ,
292
+ basename : "Some File.m" ,
293
+ path : "SomeFolder/Some Path.m" ,
294
+ sourceTree : 'BUILT_PRODUCTS_DIR'
295
+ } ,
296
+ fileRefSection = newProj . pbxFileReferenceSection ( ) ;
297
+
298
+ newProj . addToPbxFileReferenceSection ( file ) ;
299
+ test . equal ( fileRefSection [ file . fileRef ] . name , '"Some File.m"' ) ;
300
+ test . equal ( fileRefSection [ file . fileRef ] . path , '"SomeFolder/Some Path.m"' ) ;
301
+ test . done ( ) ;
302
+ }
303
+ }
304
+
0 commit comments