|
| 1 | +var fullProject = require('./fixtures/full-project') |
| 2 | + fullProjectStr = JSON.stringify(fullProject), |
| 3 | + pbx = require('../lib/pbxProject'), |
| 4 | + pbxFile = require('../lib/pbxFile'), |
| 5 | + proj = new pbx('.'); |
| 6 | + |
| 7 | +function cleanHash() { |
| 8 | + return JSON.parse(fullProjectStr); |
| 9 | +} |
| 10 | + |
| 11 | +exports.setUp = function (callback) { |
| 12 | + proj.hash = cleanHash(); |
| 13 | + callback(); |
| 14 | +} |
| 15 | + |
| 16 | +exports.removeFramework = { |
| 17 | + 'should return a pbxFile': function (test) { |
| 18 | + var newFile = proj.addFramework('libsqlite3.dylib'); |
| 19 | + |
| 20 | + test.equal(newFile.constructor, pbxFile); |
| 21 | + |
| 22 | + var deletedFile = proj.removeFramework('libsqlite3.dylib'); |
| 23 | + |
| 24 | + test.equal(deletedFile.constructor, pbxFile); |
| 25 | + |
| 26 | + test.done() |
| 27 | + }, |
| 28 | + 'should set a fileRef on the pbxFile': function (test) { |
| 29 | + var newFile = proj.addFramework('libsqlite3.dylib'); |
| 30 | + |
| 31 | + test.ok(newFile.fileRef); |
| 32 | + |
| 33 | + var deletedFile = proj.removeFramework('libsqlite3.dylib'); |
| 34 | + |
| 35 | + test.ok(deletedFile.fileRef); |
| 36 | + |
| 37 | + test.done() |
| 38 | + }, |
| 39 | + 'should remove 2 fields from the PBXFileReference section': function (test) { |
| 40 | + var newFile = proj.addFramework('libsqlite3.dylib'); |
| 41 | + fileRefSection = proj.pbxFileReferenceSection(), |
| 42 | + frsLength = Object.keys(fileRefSection).length; |
| 43 | + |
| 44 | + test.equal(68, frsLength); |
| 45 | + test.ok(fileRefSection[newFile.fileRef]); |
| 46 | + test.ok(fileRefSection[newFile.fileRef + '_comment']); |
| 47 | + |
| 48 | + var deletedFile = proj.removeFramework('libsqlite3.dylib'); |
| 49 | + frsLength = Object.keys(fileRefSection).length; |
| 50 | + |
| 51 | + test.equal(66, frsLength); |
| 52 | + test.ok(!fileRefSection[deletedFile.fileRef]); |
| 53 | + test.ok(!fileRefSection[deletedFile.fileRef + '_comment']); |
| 54 | + |
| 55 | + test.done(); |
| 56 | + }, |
| 57 | + 'should remove 2 fields from the PBXBuildFile section': function (test) { |
| 58 | + var newFile = proj.addFramework('libsqlite3.dylib'), |
| 59 | + buildFileSection = proj.pbxBuildFileSection(), |
| 60 | + bfsLength = Object.keys(buildFileSection).length; |
| 61 | + |
| 62 | + test.equal(60, bfsLength); |
| 63 | + test.ok(buildFileSection[newFile.uuid]); |
| 64 | + test.ok(buildFileSection[newFile.uuid + '_comment']); |
| 65 | + |
| 66 | + var deletedFile = proj.removeFramework('libsqlite3.dylib'); |
| 67 | + |
| 68 | + bfsLength = Object.keys(buildFileSection).length; |
| 69 | + |
| 70 | + test.equal(58, bfsLength); |
| 71 | + test.ok(!buildFileSection[deletedFile.uuid]); |
| 72 | + test.ok(!buildFileSection[deletedFile.uuid + '_comment']); |
| 73 | + |
| 74 | + test.done(); |
| 75 | + }, |
| 76 | + 'should remove from the Frameworks PBXGroup': function (test) { |
| 77 | + var newLength = proj.pbxGroupByName('Frameworks').children.length + 1, |
| 78 | + newFile = proj.addFramework('libsqlite3.dylib'), |
| 79 | + frameworks = proj.pbxGroupByName('Frameworks'); |
| 80 | + |
| 81 | + test.equal(frameworks.children.length, newLength); |
| 82 | + |
| 83 | + var deletedFile = proj.removeFramework('libsqlite3.dylib'), |
| 84 | + newLength = newLength - 1; |
| 85 | + |
| 86 | + test.equal(frameworks.children.length, newLength); |
| 87 | + |
| 88 | + test.done(); |
| 89 | + }, |
| 90 | + 'should remove from the PBXFrameworksBuildPhase': function (test) { |
| 91 | + var newFile = proj.addFramework('libsqlite3.dylib'), |
| 92 | + frameworks = proj.pbxFrameworksBuildPhaseObj(); |
| 93 | + |
| 94 | + test.equal(frameworks.files.length, 16); |
| 95 | + |
| 96 | + var deletedFile = proj.removeFramework('libsqlite3.dylib'), |
| 97 | + frameworks = proj.pbxFrameworksBuildPhaseObj(); |
| 98 | + |
| 99 | + test.equal(frameworks.files.length, 15); |
| 100 | + |
| 101 | + test.done(); |
| 102 | + } |
| 103 | +} |
0 commit comments