<commit_before>/* jslint node: true */
/* global BOT_DIR, LIBS_DIR, MODULES_DIR */
'use strict';

//set main entry point path
global.BOT_DIR = require('path').resolve(__dirname, '..');
global.LIBS_DIR = require('path').resolve(BOT_DIR, 'libs');
global.MODULES_DIR = require('path').resolve(BOT_DIR, 'modules');

var vows = require('vows'),
	assert = require('assert');

var suite = vows.describe('Config class');

//disable logger
require(LIBS_DIR + '/logger').enabled = false;

//isError assert
assert.isError = function(val) {
	assert.isObject(val);
	assert.instanceOf(val, Error);
};

var Config = require(LIBS_DIR + '/config').Config;

suite.addBatch({
	'When i construct class': {
		topic: function() {
			return new Config();
		},
		'then i get Config': function(c) {
			assert.isObject(c);
			assert.instanceOf(c, Config);
		}
	},
	'When i load config': {
		topic: function() {
			return new Config().load({
				'test': true,
				'test2': 'ok'
			});
		},
		'then i get the loaded config loaded': function(c) {
			assert.isObject(c);
			assert.isTrue(c.test);
			assert.equal(c.test2, 'ok');
		}
	},
	'When i clear config': {
		topic: function() {
			var cc = new Config();
			cc.test = true;
			cc.test2 = false;
			return cc.clear();
		},
		'then i get the config cleared': function(c) {
			assert.isObject(c);
			assert.isUndefined(c.test);
			assert.isUndefined(c.test2);
		}
	}
});

suite.export(module);<commit_msg>config testy<commit_after>/* jslint node: true */
/* global BOT_DIR, LIBS_DIR, MODULES_DIR */

//mocha globals
/* global describe, it, before, after, beforeEach, afterEach */

//strict
'use strict';

//set main entry point path
global.BOT_DIR = require('path').resolve(__dirname, '..');
global.LIBS_DIR = require('path').resolve(BOT_DIR, 'libs');
global.MODULES_DIR = require('path').resolve(BOT_DIR, 'modules');

//disable logger
require(LIBS_DIR + '/logger').enabled = false;

//load assert lib
var assert = require('assert');

//assert helpers
assert.isError = function(val) {
	assert.isObject(val);
	assert.instanceOf(val, Error);
};

assert.isObject = function(o) {
	return typeof o === 'object';
};

assert.instanceOf = function(real, expected) {
	return real instanceof expected;
};

assert.isTrue = function(v) {
	return v === true;
};

assert.isFalse = function(v) {
	return v === false;
};

assert.isUndefined = function(v) {
	return typeof v === 'undefined';
};

//and letz go
var Config = require(LIBS_DIR + '/config');

describe('Config lib', function() {
	describe('class construction', function() {
		it('should return \'Config\' instance', function() {
			assert.isObject(Config);
			assert.instanceOf(new Config.Config(), Config.Config);
			assert.instanceOf(Config.create(), Config.Config);
		});
	});

	var config;
	beforeEach(function() {
		config = Config.create();
		config.test2 = 'error';
		config.test3 = 'derp';
	});

	describe('config load', function() {
		it('should load the config', function() {
			config.load({
				'test': true,
				'test2': 'ok'
			});

			assert.isTrue(config.test);
			assert.equal(config.test2, 'ok');
			assert.equal(config.test3, 'derp');
		});
	});

	describe('config clear', function() {
		it('should clear the config', function() {
			config.clear();
			assert.isUndefined(config.test2);
			assert.isUndefined(config.test3);
		});
	});
});
{'fraction_non_alphanumeric': 0.18135338345864663, 'fraction_numerical': 0.0033082706766917294, 'mean_word_length': 4.1248073959938365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3995369', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1137, 'n_words': 260}