added tests to cli
This commit is contained in:
parent
6bc78b1d66
commit
10ca07840c
10
cli.js
10
cli.js
|
@ -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');
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
});
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue