Skip to content

Commit

Permalink
rewrite file in before and after functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam De Maeyer committed Mar 24, 2017
1 parent bc486a7 commit bc1241f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/unit/commands/generate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,26 @@ describe('generate command', function() {
td.reset();
});

it('runs GenerateFromBlueprint but with null nodeModulesPath', function() {
command.project.hasDependencies = function() { return false; };
let originalYarnLockPath = path.join(command.project.root, 'yarn.lock');
let dummyYarnLockPath = path.join(command.project.root, 'foo.bar');
fs.renameSync(originalYarnLockPath, dummyYarnLockPath);
describe('without yarn.lock file', function() {
let originalYarnLockPath, dummyYarnLockPath;

return expect(command.validateAndRun(['controller', 'foo'])).to.be.rejected.then(reason => {
expect(reason.message).to.eql('node_modules appears empty, you may need to run `npm install`');
}).then(() => fs.renameSync(dummyYarnLockPath, originalYarnLockPath));
beforeEach(function() {
originalYarnLockPath = path.join(command.project.root, 'yarn.lock');
dummyYarnLockPath = path.join(command.project.root, 'foo.bar');
fs.renameSync(originalYarnLockPath, dummyYarnLockPath);
});

afterEach(function() {
fs.renameSync(dummyYarnLockPath, originalYarnLockPath);
});

it('runs GenerateFromBlueprint but with null nodeModulesPath with npm', function() {
command.project.hasDependencies = function() { return false; };

return expect(command.validateAndRun(['controller', 'foo'])).to.be.rejected.then(reason => {
expect(reason.message).to.eql('node_modules appears empty, you may need to run `npm install`');
});
});
});

it('runs GenerateFromBlueprint but with null nodeModulesPath with yarn', function() {
Expand Down

0 comments on commit bc1241f

Please sign in to comment.