|
| 1 | +var fullProject = require('./fixtures/full-project') |
| 2 | + fullProjectStr = JSON.stringify(fullProject), |
| 3 | + pbx = require('../lib/pbxProject'), |
| 4 | + proj = new pbx('.'), |
| 5 | + debugConfiguration = { |
| 6 | + isa: 'XCBuildConfiguration', |
| 7 | + buildSettings: { |
| 8 | + GCC_PREPROCESSOR_DEFINITIONS: [ |
| 9 | + '"DEBUG=1"', |
| 10 | + '"$(inherited)"', |
| 11 | + ], |
| 12 | + INFOPLIST_FILE: "Info.Plist", |
| 13 | + LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', |
| 14 | + PRODUCT_NAME: '"${TARGET_NAME}"', |
| 15 | + SKIP_INSTALL: 'YES' |
| 16 | + }, |
| 17 | + name: 'Debug' |
| 18 | + }, |
| 19 | + releaseConfiguration = { |
| 20 | + isa: 'XCBuildConfiguration', |
| 21 | + buildSettings: { |
| 22 | + INFOPLIST_FILE: "Info.Plist", |
| 23 | + LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', |
| 24 | + PRODUCT_NAME: '"${TARGET_NAME}"', |
| 25 | + SKIP_INSTALL: 'YES' |
| 26 | + }, |
| 27 | + name: 'Release' |
| 28 | + }; |
| 29 | + |
| 30 | +function cleanHash() { |
| 31 | + return JSON.parse(fullProjectStr); |
| 32 | +} |
| 33 | + |
| 34 | +exports.setUp = function (callback) { |
| 35 | + proj.hash = cleanHash(); |
| 36 | + callback(); |
| 37 | +} |
| 38 | + |
| 39 | +exports.addXCConfigurationList = { |
| 40 | + 'should return an XCConfigurationList': function (test) { |
| 41 | + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), |
| 42 | + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); |
| 43 | + |
| 44 | + test.ok(typeof xcConfigurationList === 'object'); |
| 45 | + test.done(); |
| 46 | + }, |
| 47 | + 'should set a uuid on the XCConfigurationList': function (test) { |
| 48 | + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), |
| 49 | + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); |
| 50 | + |
| 51 | + test.ok(xcConfigurationList.uuid); |
| 52 | + test.done(); |
| 53 | + }, |
| 54 | + 'should add configurations to pbxBuildConfigurationSection': function (test) { |
| 55 | + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), |
| 56 | + pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), |
| 57 | + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), |
| 58 | + xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations; |
| 59 | + |
| 60 | + for (var index = 0; index < xcConfigurationListConfigurations.length; index++) { |
| 61 | + var configuration = xcConfigurationListConfigurations[index]; |
| 62 | + test.ok(pbxBuildConfigurationSection[configuration.value]); |
| 63 | + } |
| 64 | + |
| 65 | + test.done(); |
| 66 | + }, |
| 67 | + 'should add XCConfigurationList to pbxXCConfigurationListSection': function (test) { |
| 68 | + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), |
| 69 | + pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); |
| 70 | + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); |
| 71 | + |
| 72 | + test.ok(pbxXCConfigurationListSection[xcConfigurationList.uuid]); |
| 73 | + test.done(); |
| 74 | + }, |
| 75 | + 'should add XCConfigurationList object correctly': function (test) { |
| 76 | + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), |
| 77 | + pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); |
| 78 | + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), |
| 79 | + xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; |
| 80 | + |
| 81 | + test.deepEqual(xcConfigurationListInPbx, xcConfigurationList.xcConfigurationList); |
| 82 | + test.done(); |
| 83 | + }, |
| 84 | + 'should add correct configurations to XCConfigurationList and to pbxBuildConfigurationSection': function (test) { |
| 85 | + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), |
| 86 | + pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); |
| 87 | + pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), |
| 88 | + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), |
| 89 | + xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations, |
| 90 | + expectedConfigurations = [], |
| 91 | + xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; |
| 92 | + |
| 93 | + for (var index = 0; index < xcConfigurationListConfigurations.length; index++) { |
| 94 | + var configuration = xcConfigurationListConfigurations[index]; |
| 95 | + expectedConfigurations.push(pbxBuildConfigurationSection[configuration.value]); |
| 96 | + } |
| 97 | + |
| 98 | + test.deepEqual(expectedConfigurations, [debugConfiguration, releaseConfiguration]); |
| 99 | + test.deepEqual(xcConfigurationListInPbx.buildConfigurations, xcConfigurationListConfigurations); |
| 100 | + test.done(); |
| 101 | + }, |
| 102 | + 'should set comments for pbxBuildConfigurations': function (test) { |
| 103 | + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), |
| 104 | + pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), |
| 105 | + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), |
| 106 | + xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations; |
| 107 | + |
| 108 | + for (var index = 0; index < xcConfigurationListConfigurations.length; index++) { |
| 109 | + var configuration = xcConfigurationListConfigurations[index]; |
| 110 | + test.ok(pbxBuildConfigurationSection[configuration.value + '_comment']); |
| 111 | + } |
| 112 | + |
| 113 | + test.done(); |
| 114 | + } |
| 115 | +} |
0 commit comments