"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const index_js_1 = require("../errors/index.js");
const env_js_1 = require("./env.js");
(0, vitest_1.describe)('env store', () => {
    (0, vitest_1.test)('errors when variable not set', () => {
        const envStore = new env_js_1.EnvStore({
            test1: 'value1'
        });
        (0, vitest_1.expect)(() => {
            envStore.add({ name: 'test2' });
        }).toThrowError(index_js_1.InvalidConfigurationError);
        (0, vitest_1.expect)(() => {
            envStore.addAll([{ name: 'test2' }, { name: 'test3', defaultValue: 'foo' }]);
        }).toThrowError(index_js_1.InvalidConfigurationError);
    });
    (0, vitest_1.test)('can fetch value', () => {
        const envStore = new env_js_1.EnvStore({
            test1: 'value1',
            test2: 'value2'
        });
        envStore.add({ name: 'test1' });
        envStore.addAll([{ name: 'test2' }, { name: 'test3', defaultValue: 'value3' }]);
        (0, vitest_1.expect)(envStore.get('test1')).toBe('value1');
        (0, vitest_1.expect)(envStore.get('test2')).toBe('value2');
        (0, vitest_1.expect)(envStore.get('test3')).toBe('value3');
    });
    (0, vitest_1.test)('errors when fetching value if not added', () => {
        const envStore = new env_js_1.EnvStore({
            test1: 'value1',
            test2: 'value2'
        });
        envStore.add({ name: 'test1' });
        (0, vitest_1.expect)(() => {
            envStore.get('test2');
        }).toThrowError(index_js_1.InvalidConfigurationError);
    });
    (0, vitest_1.test)('errors when fetching value if not added', () => {
        const envStore = new env_js_1.EnvStore({
            test1: 'value1',
            test2: 'value2'
        });
        envStore.add({ name: 'test', regex: 'test.*', defaultValue: {} });
        (0, vitest_1.expect)(envStore.get('test')).toEqual({ test1: 'value1', test2: 'value2' });
    });
});
//# sourceMappingURL=env.test.js.map