From 7e1d7a703f8e6c1de1aacb5c623d6c38f29ef1c6 Mon Sep 17 00:00:00 2001 From: Micooz Date: Sun, 20 Aug 2017 19:55:41 +0800 Subject: [PATCH] core: add missing tests for config.js --- src/core/__tests__/config.test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/core/__tests__/config.test.js b/src/core/__tests__/config.test.js index d89d348..7e74909 100644 --- a/src/core/__tests__/config.test.js +++ b/src/core/__tests__/config.test.js @@ -46,6 +46,27 @@ describe('Config#init', function () { expect(() => Config.init({...baseConf, timeout: 61})).not.toThrow(); }); + it('should throw when behaviours(if provided) is invalid', function () { + expect(() => Config.init({...baseConf, behaviours: null})).toThrow(); + expect(() => Config.init({...baseConf, behaviours: {}})).not.toThrow(); + expect(() => Config.init({...baseConf, behaviours: {'abc': {}}})).toThrow(); + expect(() => Config.init({...baseConf, behaviours: {'on-preset-failed': {}}})).toThrow(); + expect(() => Config.init({...baseConf, behaviours: {'on-preset-failed': {name: null}}})).toThrow(); + expect(() => Config.init({...baseConf, behaviours: {'on-preset-failed': {name: ''}}})).toThrow(); + expect(() => Config.init({ + ...baseConf, + behaviours: {'on-preset-failed': {name: 'direct-close', params: []}} + })).toThrow(); + expect(() => Config.init({ + ...baseConf, + behaviours: {'on-preset-failed': {name: 'direct-close'}} + })).not.toThrow(); + expect(() => Config.init({ + ...baseConf, + behaviours: {'on-preset-failed': {name: 'direct-close', params: {}}} + })).not.toThrow(); + }); + it('should throw when log_path(if provided) is invalid', function () { expect(() => Config.init({...baseConf, log_path: null})).toThrow(); expect(() => Config.init({...baseConf, log_path: ''})).not.toThrow();