Skip to content

Commit

Permalink
test(twconf): Add testcase for emmit error on pass invalid type in co…
Browse files Browse the repository at this point in the history
…nfig rule position.
  • Loading branch information
CheerlessCloud committed Aug 14, 2017
1 parent 626b3ba commit c56ee87
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('twconfig main tests', () => {

it('simple smoke test', () => {
expect(() => {
// eslint-disable-next-line no-new
const conf = new TwConf({
'database.mongodb.hostname': {
comment: 'hostname of mongodb',
Expand All @@ -37,13 +36,20 @@ describe('twconfig main tests', () => {
}).not.to.throw();
});

it('throw error on invalid config rule type', () => {
expect(() => {
// eslint-disable-next-line no-new
new TwConf({ 'database.mongodb.hostname': 'invalid value' });
}).to.be.throws('Config rule must be an object');
});


it('splitter', () => {
process.env = {
NODE_ENV: 'production',
};

expect(() => {
// eslint-disable-next-line no-new
const conf = new TwConf({
nodeEnv: {
comment: 'env mode',
Expand Down

0 comments on commit c56ee87

Please sign in to comment.