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

Version Path
coprl-3.0.0.beta.12 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.11 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.10 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.9 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.8 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.7 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.6 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.5 views/mdc/assets/js/utils/config.test.js
voom-presenters-2.1.2 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.4 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.3 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.2 views/mdc/assets/js/utils/config.test.js
coprl-3.0.0.beta.1 views/mdc/assets/js/utils/config.test.js
voom-presenters-2.1.0 views/mdc/assets/js/utils/config.test.js
voom-presenters-2.0.3 views/mdc/assets/js/utils/config.test.js
voom-presenters-2.0.2 views/mdc/assets/js/utils/config.test.js
voom-presenters-2.0.1 views/mdc/assets/js/utils/config.test.js
voom-presenters-2.0.0 views/mdc/assets/js/utils/config.test.js
voom-presenters-0.2.0 views/mdc/assets/js/utils/config.test.js