1+ var jsonProject = require ( './fixtures/full-project' )
2+ fullProjectStr = JSON . stringify ( jsonProject ) ,
3+ pbx = require ( '../lib/pbxProject' ) ,
4+ pbxFile = require ( '../lib/pbxFile' ) ,
5+ myProj = new pbx ( '.' ) ;
6+
7+ function cleanHash ( ) {
8+ return JSON . parse ( fullProjectStr ) ;
9+ }
10+
11+ exports . setUp = function ( callback ) {
12+ myProj . hash = cleanHash ( ) ;
13+ callback ( ) ;
14+ }
15+
16+ exports [ 'addToPbxFileReferenceSection function' ] = {
17+ 'should add file and comment to fileReferenceSection' : function ( test ) {
18+ var file = new pbxFile ( 'file.m' ) ;
19+ file . fileRef = myProj . generateUuid ( ) ;
20+
21+ myProj . addToPbxFileReferenceSection ( file )
22+
23+ test . equal ( myProj . pbxFileReferenceSection ( ) [ file . fileRef ] . isa , 'PBXFileReference' ) ;
24+ test . equal ( myProj . pbxFileReferenceSection ( ) [ file . fileRef ] . lastKnownFileType , 'sourcecode.c.objc' ) ;
25+ test . equal ( myProj . pbxFileReferenceSection ( ) [ file . fileRef ] . name , '"file.m"' ) ;
26+ test . equal ( myProj . pbxFileReferenceSection ( ) [ file . fileRef ] . path , '"file.m"' ) ;
27+ test . equal ( myProj . pbxFileReferenceSection ( ) [ file . fileRef ] . sourceTree , '"<group>"' ) ;
28+ test . equal ( myProj . pbxFileReferenceSection ( ) [ file . fileRef ] . fileEncoding , 4 ) ;
29+ test . equal ( myProj . pbxFileReferenceSection ( ) [ file . fileRef + "_comment" ] , 'file.m' ) ;
30+ test . done ( ) ;
31+ } ,
32+ 'should add file with preset explicitFileType to fileReferenceSection correctly' : function ( test ) {
33+ var appexFile = { fileRef : myProj . generateUuid ( ) , isa : 'PBXFileReference' , explicitFileType : '"wrapper.app-extension"' , path : "WatchKit Extension.appex" } ;
34+
35+ myProj . addToPbxFileReferenceSection ( appexFile )
36+
37+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . isa , 'PBXFileReference' ) ;
38+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . explicitFileType , '"wrapper.app-extension"' ) ;
39+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . path , '"WatchKit Extension.appex"' ) ;
40+ test . done ( ) ;
41+ } ,
42+ 'should add file with preset includeInIndex to fileReferenceSection correctly' : function ( test ) {
43+ var appexFile = { fileRef : myProj . generateUuid ( ) , isa : 'PBXFileReference' , includeInIndex : 0 , path : "WatchKit Extension.appex" } ;
44+
45+ myProj . addToPbxFileReferenceSection ( appexFile )
46+
47+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . isa , 'PBXFileReference' ) ;
48+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . includeInIndex , 0 ) ;
49+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . path , '"WatchKit Extension.appex"' ) ;
50+ test . done ( ) ;
51+ } ,
52+ 'should add file with preset sourceTree to fileReferenceSection correctly' : function ( test ) {
53+ var appexFile = { fileRef : myProj . generateUuid ( ) , isa : 'PBXFileReference' , sourceTree : 'BUILT_PRODUCTS_DIR' , path : "WatchKit Extension.appex" } ;
54+
55+ myProj . addToPbxFileReferenceSection ( appexFile )
56+
57+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . isa , 'PBXFileReference' ) ;
58+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . sourceTree , 'BUILT_PRODUCTS_DIR' ) ;
59+ test . equal ( myProj . pbxFileReferenceSection ( ) [ appexFile . fileRef ] . path , '"WatchKit Extension.appex"' ) ;
60+ test . done ( ) ;
61+ }
62+ }
0 commit comments