Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Adds Testing to CLI #727

Merged
merged 3 commits into from
Jun 11, 2015
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions local-cli/__tests__/setupPodfileTests.js
Original file line number Diff line number Diff line change
@@ -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");
});
});
14 changes: 14 additions & 0 deletions local-cli/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ module.exports = {
throw e;
}
}

return {
podfileExists: function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Expand Down