<commit_before>'use strict';

const expect = require('chai').expect;

describe('requiring', () => {
    it('should not throw an error', () => {
        expect(() => require('./lib')).to.not.throw();
    });
});

describe('initializing', () => {
    let ConfigLive;

    beforeEach(() => {
        ConfigLive = require('./lib');
    });

    it('should throw an error when no or invalid host is specified', () => {
        expect(() => new ConfigLive()).to.throw(/Invalid host type. Must be a string\./);
        expect(() => new ConfigLive(123)).to.throw(/Invalid host type. Must be a string\./);
        expect(() => new ConfigLive({})).to.throw(/Invalid host type. Must be a string\./);
    });

    it('should throw an error when no or invalid port is specified', () => {
        expect(() => new ConfigLive('localhost')).to.throw(/Invalid port type. Must be a number\./);
        expect(() => new ConfigLive('localhost', '123')).to.throw(/Invalid port type. Must be a number\./);
        expect(() => new ConfigLive('localhost', {})).to.throw(/Invalid port type. Must be a number\./);
    });

    it('should not throw an error when host and port are valid', () => {
        expect(() => new ConfigLive('localhost', 6379)).to.not.throw();
    });
});

describe('events', () => {
    const host        = 'localhost';
    const port        = 6379;
    const ConfigLive  = require('./lib');
    const cl          = new ConfigLive(host, port);
    const redis       = require('redis');
    const redisClient = redis.createClient(port, host);

    beforeEach(done => {
        redisClient.unref();
        redisClient.del('config-live:config', done);
    });<commit_msg>moved require out of each<commit_after>'use strict';

const expect = require('chai').expect;

describe('requiring', () => {
    it('should not throw an error', () => {
        expect(() => require('./lib')).to.not.throw();
    });
});

describe('initializing', () => {
    const ConfigLive = require('./lib');

    it('should throw an error when no or invalid host is specified', () => {
        expect(() => new ConfigLive()).to.throw(/Invalid host type. Must be a string\./);
        expect(() => new ConfigLive(123)).to.throw(/Invalid host type. Must be a string\./);
        expect(() => new ConfigLive({})).to.throw(/Invalid host type. Must be a string\./);
    });

    it('should throw an error when no or invalid port is specified', () => {
        expect(() => new ConfigLive('localhost')).to.throw(/Invalid port type. Must be a number\./);
        expect(() => new ConfigLive('localhost', '123')).to.throw(/Invalid port type. Must be a number\./);
        expect(() => new ConfigLive('localhost', {})).to.throw(/Invalid port type. Must be a number\./);
    });

    it('should not throw an error when host and port are valid', () => {
        expect(() => new ConfigLive('localhost', 6379)).to.not.throw();
    });
});

describe('events', () => {
    const host        = 'localhost';
    const port        = 6379;
    const ConfigLive  = require('./lib');
    const cl          = new ConfigLive(host, port);
    const redis       = require('redis');
    const redisClient = redis.createClient(port, host);

    beforeEach(done => {
        redisClient.unref();
        redisClient.del('config-live:config', done);
    });
{'fraction_non_alphanumeric': 0.19090909090909092, 'fraction_numerical': 0.008484848484848486, 'mean_word_length': 2.755403868031854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 36, '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': '3964414', 'n_tokens_mistral': 956, 'n_tokens_neox': 928, 'n_words': 278}