<commit_before>const chai = require('chai');
const chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
const assert = chai.assert;

describe('Cloudformation Extensions.cfnex', function(){
	
	let cfnex;

	const logger = {
		debug: console.log,
		error: console.log
	};

	it('should init fine', function(){
		cfnex = require('../../lib/cfnex');
	});

	it('should have the correct methods', function(){
		let props = ['loadExtensions', 'parse', 'parseStatement'];
		props.forEach(function(prop){
			assert.isDefined(cfnex[prop]);
			assert.typeOf(cfnex[prop], 'Function', 'is a function');
		});
	});

	describe('loadExtensions', function(){

		it('should load the given extensions', function(){
			const context = {
				logger: logger,
				cwd: '.',
				config: {
					extensionsDirectory: "extensions"
				}
			};
			assert.isFulfilled(cfnex.loadExtensions(context));
		});

		it('should error if it can\'t find the given extensions directory', function(){
			const context = {
				logger: logger,
				cwd: '..',
				config: {
					extensionsDirectory: "extensions"
				}
			};
			assert.isRejected(cfnex.loadExtensions(context));
		});
	});

	describe('parse', function(){
		it('should parse the given object', function(){

		});
		it('should error if given an unparsable object', function(){
			
		});
	});

	describe('parseStatement', function(){
		it('should parse the given statement', function(){

		});
		it('should error if given an unparsable statement', function(){
			
		});
	});

});<commit_msg>lib/cfnex.js tests<commit_after>const chai = require('chai');
const chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
const assert = chai.assert;

describe('Cloudformation Extensions.cfnex', function(){
	
	let cfnex;

	const logger = {
		debug: () => {},
		error: () => {},
	};

	it('should init fine', function(){
		cfnex = require('../../lib/cfnex');
	});

	it('should have the correct methods', function(){
		let props = ['loadExtensions', 'parse', 'parseStatement'];
		props.forEach(function(prop){
			assert.isDefined(cfnex[prop]);
			assert.typeOf(cfnex[prop], 'Function', 'is a function');
		});
	});

	describe('loadExtensions', function(){

		it('should load the given extensions', function(){
			const context = {
				logger: logger,
				cwd: '.',
				config: {
					extensionsDirectory: "extensions"
				}
			};
			assert.isFulfilled(cfnex.loadExtensions(context));
		});

		it('should error if it can\'t find the given extensions directory', function(){
			const context = {
				logger: logger,
				cwd: '..',
				config: {
					extensionsDirectory: "extensions"
				}
			};
			assert.isRejected(cfnex.loadExtensions(context));
		});
	});

	describe('parse', () => {
		it('should parse the given object', function(){
			const context = {
				logger: logger,
				cwd: '.',
				config: {
					extensionsDirectory: "extensions"
				}
			};
			const obj = {};
			const parent = {};
			const pKey = 'testing';
			parent[pKey] = obj;
			const args = {
				obj,
				parent,
				pKey,
				context
			};
			assert.isFulfilled(cfnex.parse(args));
		});
		it('should error if given an unparsable object', function(){
			const context = {
				logger: logger,
				cwd: '.',
				config: {
					extensionsDirectory: "extensions"
				}
			};
			const obj = {};
			const parent = {};
			const pKey = '';
			parent['testing'] = obj;
			const args = {
				obj,
				parent,
				pKey,
				context
			};
			assert.isRejected(cfnex.parse(args));
		});
	});

	describe('parseStatement', function(){
		it('should parse the given statement', function(){
			const statement = { 'cfnex::anExtension': ['thing1', 'thing2'] };
			const result = cfnex.parseStatement(statement);
			const expected = {
				extensionName: 'anExtension',
				args: ['thing1', 'thing2']
			};
			assert.deepEqual(result, expected);
		});
		it('should error if given an unparsable statement', function(){
			const statement = { 'cfnexfljfanExtension': ['thing1', 'thing2'] };
			try {
				cfnex.parseStatement(statement);
			} catch (e) {
				assert(e);
			}
		});
	});

});
{'fraction_non_alphanumeric': 0.170056358735604, 'fraction_numerical': 0.001470227885322225, 'mean_word_length': 3.470974808324206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4356544', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1266, 'n_words': 300}