Skip to content

Commit

Permalink
adds unit test for install.renameService function
Browse files Browse the repository at this point in the history
  • Loading branch information
laardee committed Nov 4, 2016
1 parent 574ef4b commit af53bcb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/plugins/install/tests/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ describe('Install', () => {
install.install.restore();
});
});

it('should set new service value in serverless.yml and name value in package.json', (done) => {
const defaultServiceName = 'service-name';
const newServiceName = 'new-service-name';

const servicePath = testUtils.getTmpDirPath();
const serviceFile = path.join(servicePath, 'serverless.yml');
const packageFile = path.join(servicePath, 'package.json');

serverless.utils.writeFileSync(serviceFile, { service: defaultServiceName });
serverless.utils.writeFileSync(packageFile, { name: defaultServiceName });

install.renameService(newServiceName, servicePath)
.then(() => {
const serviceYml = serverless.utils.readFileSync(serviceFile);
const packageJson = serverless.utils.readFileSync(packageFile);
expect(serviceYml.service).to.equal(newServiceName);
expect(packageJson.name).to.equal(newServiceName);
done();
})
.catch(done);
});
});

describe('#install()', () => {
Expand Down

0 comments on commit af53bcb

Please sign in to comment.