|
| 1 | +var fullProject = require('./fixtures/full-project') |
| 2 | + fullProjectStr = JSON.stringify(fullProject), |
| 3 | + pbx = require('../lib/pbxProject'), |
| 4 | + proj = new pbx('.'); |
| 5 | + |
| 6 | +function cleanHash() { |
| 7 | + return JSON.parse(fullProjectStr); |
| 8 | +} |
| 9 | + |
| 10 | +exports.setUp = function (callback) { |
| 11 | + proj.hash = cleanHash(); |
| 12 | + callback(); |
| 13 | +} |
| 14 | + |
| 15 | +exports.addBuildPhase = { |
| 16 | + 'should return a pbxBuildPhase': function (test) { |
| 17 | + var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); |
| 18 | + |
| 19 | + test.ok(typeof buildPhase === 'object'); |
| 20 | + test.done() |
| 21 | + }, |
| 22 | + 'should set a uuid on the pbxBuildPhase': function (test) { |
| 23 | + var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); |
| 24 | + |
| 25 | + test.ok(buildPhase.uuid); |
| 26 | + test.done() |
| 27 | + }, |
| 28 | + 'should add all files to build phase': function (test) { |
| 29 | + var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase'); |
| 30 | + for (var index = 0; index < buildPhase.files.length; index++) { |
| 31 | + var file = buildPhase.files[index]; |
| 32 | + test.ok(file.value); |
| 33 | + } |
| 34 | + |
| 35 | + test.done() |
| 36 | + }, |
| 37 | + 'should add the PBXBuildPhase object correctly': function (test) { |
| 38 | + var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase'), |
| 39 | + buildPhaseInPbx = proj.buildPhaseObject('PBXResourcesBuildPhase', 'My build phase'); |
| 40 | + |
| 41 | + test.equal(buildPhaseInPbx, buildPhase); |
| 42 | + test.equal(buildPhaseInPbx.isa, 'PBXResourcesBuildPhase'); |
| 43 | + test.equal(buildPhaseInPbx.buildActionMask, 2147483647); |
| 44 | + test.equal(buildPhaseInPbx.runOnlyForDeploymentPostprocessing, 0); |
| 45 | + test.done(); |
| 46 | + }, |
| 47 | + 'should add each of the files to PBXBuildFile section': function (test) { |
| 48 | + var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase'), |
| 49 | + buildFileSection = proj.pbxBuildFileSection(); |
| 50 | + |
| 51 | + for (var index = 0; index < buildPhase.files.length; index++) { |
| 52 | + var file = buildPhase.files[index]; |
| 53 | + test.ok(buildFileSection[file.value]); |
| 54 | + } |
| 55 | + |
| 56 | + test.done(); |
| 57 | + }, |
| 58 | + 'should add each of the files to PBXFileReference section': function (test) { |
| 59 | + var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase'), |
| 60 | + fileRefSection = proj.pbxFileReferenceSection(), |
| 61 | + buildFileSection = proj.pbxBuildFileSection(), |
| 62 | + fileRefs = []; |
| 63 | + |
| 64 | + for (var index = 0; index < buildPhase.files.length; index++) { |
| 65 | + var file = buildPhase.files[index]; |
| 66 | + fileRefs.push(buildFileSection[file.value].fileRef); |
| 67 | + } |
| 68 | + |
| 69 | + for (var index = 0; index < fileRefs.length; index++) { |
| 70 | + var fileRef = fileRefs[index]; |
| 71 | + test.ok(fileRefSection[fileRef]); |
| 72 | + } |
| 73 | + |
| 74 | + test.done(); |
| 75 | + } |
| 76 | +} |
0 commit comments