Sha256: e9a10d0e31a2b062574f501c3d492dd97ea524fa847093887930b10a04485900
Contents?: true
Size: 1.44 KB
Versions: 19
Compression:
Stored size: 1.44 KB
Contents
import VConfig from './config'; const baseConfig = { foo: () => {}, aaa: { bbb: { ccc: { ddd: true, eee: undefined, fff: 5, }, ggg: 'string', }, }, }; let appConfig; beforeAll(() => { appConfig = new VConfig(baseConfig); }); test('constructs', () => { expect(new VConfig()).toBeInstanceOf(Object); }); test('get returns a value for a present key', () => { expect(appConfig.get('foo')).toBeInstanceOf(Function); }); test('get returns undefined for an absent key', () => { expect(appConfig.get('absent')).toBeUndefined(); expect(appConfig.get('absent.key')).toBeUndefined(); }); test('get handles nested keys', () => { expect(appConfig.get('aaa.bbb.ggg')).toEqual('string'); }); test('get handles empty an empty path', () => { expect(appConfig.get('')).toBeUndefined(); }); test('config returns the entire configuration object', () => { expect(appConfig.all()).toEqual(baseConfig); }); test('has returns a truthy value for a present key', () => { expect(appConfig.has('foo')).toEqual(true); }); test('has returns false for an absent key', () => { expect(appConfig.has('absent')).toEqual(false); expect(appConfig.has('absent.key')).toEqual(false); }); test('has handles nested keys', () => { expect(appConfig.has('aaa.bbb.ggg')).toEqual(true); expect(appConfig.has('aaa.bbb.absent')).toEqual(false); });
Version data entries
19 entries across 19 versions & 2 rubygems