<commit_before>import * as chai from 'chai'
import * as configMan from 'index'
import * as path from 'path'

describe('Init', () => {
    beforeEach(() => {
        configMan.reset()
    })

    context('async', () => {
        it('should initialize', async () => {
            const init: any = configMan.init({
                cwd: path.resolve(__dirname, '../mock'),
                allowUnknown: true,
                removeUnknown: true,
                configs: [
                    {type: configMan.ConfigType.DEFAULT},
                    {
                        type: configMan.ConfigType.JSON,
                        filePath: path.resolve(__dirname, '../mock/config.json')
                    }
                ]
            })
            chai.expect(init.then).to.not.be.undefined
            chai.expect(configMan.STATE.initialized).to.be.false
            await init
            chai.expect(configMan.STATE.initialized).to.be.true
            chai.expect(configMan.STATE.config).to.deep.equal({
                test1: {
                    test1a: 'test',
                    test1b: 12345,
                    test1c: null
                },
                test2: '2',
                test3: 3,
                test4: false
            })
        })
    })

    context('check', () => {
        it('should fail on unknown', async () => {
            await configMan
                .init({
                    cwd: path.resolve(__dirname, '../mock'),
                    allowUnknown: false,
                    configs: [
                        {type: configMan.ConfigType.DEFAULT},
                        {
                            type: configMan.ConfigType.JSON,
                            filePath: path.resolve(__dirname, '../mock/config.json')
                        }
                    ]
                })
                .should.eventually.be.rejectedWith(
                    'ConfigMan: invalid config\n(test11) of type <number> is unknown'
                )
        })
    })<commit_msg>Fix tests<commit_after>import * as chai from 'chai'
import * as configMan from 'index'
import * as path from 'path'

describe('Init', () => {
    beforeEach(() => {
        configMan.reset()
    })

    context('async', () => {
        it('should initialize', async () => {
            const init: any = configMan.init({
                cwd: path.resolve(__dirname, '../mock'),
                allowUnknown: true,
                removeUnknown: true,
                configs: [
                    {type: configMan.ConfigType.DEFAULT},
                    {
                        type: configMan.ConfigType.JSON,
                        filePath: path.resolve(__dirname, '../mock/config.json')
                    }
                ]
            })
            chai.expect(init.then).to.not.be.undefined
            chai.expect(configMan.STATE.initialized).to.be.false
            await init
            chai.expect(configMan.STATE.initialized).to.be.true
            chai.expect(configMan.STATE.config).to.deep.equal({
                test1: {
                    test1a: 'test',
                    test1b: 12345,
                    test1c: null
                },
                test2: '2',
                test3: 3,
                test4: false
            })
        })
    })

    context('check', () => {
        it('should fail on unknown', async () => {
            await configMan
                .init({
                    cwd: path.resolve(__dirname, '../mock'),
                    allowUnknown: false,
                    configs: [
                        {type: configMan.ConfigType.DEFAULT},
                        {
                            type: configMan.ConfigType.JSON,
                            filePath: path.resolve(__dirname, '../mock/config.json')
                        }
                    ]
                })
                .should.eventually.be.rejectedWith(
                    'ConfigMan: invalid config: (test11) of type <number> is unknown'
                )
        })
    })
{'fraction_non_alphanumeric': 0.11735700197238659, 'fraction_numerical': 0.007889546351084813, 'mean_word_length': 1.0573022312373226, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6158891', 'n_tokens_mistral': 1057, 'n_tokens_neox': 986, 'n_words': 184}