added tests to cli

This commit is contained in:
Thomas Mchugh 2015-04-07 15:11:50 -05:00
parent 6bc78b1d66
commit 10ca07840c
3 changed files with 53 additions and 9 deletions

10
cli.js
View File

@ -5,12 +5,4 @@
'use strict';
var cli = require('./local-cli/cli.js');
function run() {
cli.run();
}
module.exports = {
run: run
};
module.exports = require('./local-cli/cli.js');

View File

@ -0,0 +1,38 @@
'use strict';
jest.dontMock('../install');
var install = require('../install.js');
var fs = require('fs');
describe('setup Podfile', function() {
it('creates a Podfile', function() {
fs.mkdirSync('./podfile-test');
process.chdir('./podfile-test');
var setupPodfile = install.setupPodfile();
expect(setupPodfile.podfileExists()).toBe(true);
process.chdir('../');
});
it('expects Podfile to containing opening & closing react native tag', function() {
process.chdir('./podfile-test');
var setupPodfile = install.setupPodfile();
var openingReactTag = '#<React-Native>';
var closingReactTag = '#</React-Native>';
expect(setupPodfile.podfileText()).toContain(openingReactTag);
expect(setupPodfile.podfileText()).toContain(closingReactTag);
process.chdir('../');
});
it('expects Podfile to contain React Pod', function() {
process.chdir('./podfile-test');
var setupPodfile = install.setupPodfile();
expect(setupPodfile.podfileText()).toContain('pod \'React\'');
process.chdir('../');
fs.unlink("./podfile-test/Podfile");
fs.rmdirSync("./podfile-test");
});
});

View File

@ -83,6 +83,20 @@ module.exports = {
throw e;
}
}
return {
podfileExists: function() {
try {
var podfileText = fs.readFileSync(PODFILE_PATH, 'utf8');
return true;
} catch(e) {
return false;
}
},
podfileText: function() {
return podfileText;
}
};
},
init: function(arguement) {
// arguement is available for future arguement commands