<commit_before>/* global d3, assert, chai, D3Funnel */

describe('D3Funnel', function () {
	var getFunnel, getSvg, getBasicData, getPathHeight, getCommandHeight;

	beforeEach(function (done) {
		getFunnel = function () {
			return new D3Funnel('#funnel');
		};
		getSvg = function () {
			return d3.select('#funnel').selectAll('svg');
		};
		getBasicData = function () {
			return [['Node', 1000]];
		};
		getPathHeight = function (path) {
			var commands = path.attr('d').split(' ');

			return getCommandHeight(commands[2]) - getCommandHeight(commands[0]);
		};
		getCommandHeight = function (command) {
			return parseFloat(command.split(',')[1]);
		};

		done();
	});

	describe('constructor', function () {
		it('should instantiate without error', function () {
			new D3Funnel('#funnel');
		});
	});

	describe('methods', function () {
		describe('draw', function () {
			it('should draw a chart on the identified target', function () {
				getFunnel().draw(getBasicData(), {});

				assert.equal(1, getSvg()[0].length);
			});

			it('should draw when second argument is missing', function () {
				getFunnel().draw(getBasicData());

				assert.equal(1, getSvg()[0].length);
			});

			it('should throw an exception on invalid data', function () {<commit_msg>Move help test functions out of beforeEach<commit_after>/* global d3, assert, chai, D3Funnel */

function getFunnel() {
	return new D3Funnel('#funnel');
}

function getSvg() {
	return d3.select('#funnel').selectAll('svg');
}

function getBasicData() {
	return [['Node', 1000]];
}

function getPathHeight(path) {
	var commands = path.attr('d').split(' ');

	return getCommandHeight(commands[2]) - getCommandHeight(commands[0]);
}

function getCommandHeight(command) {
	return parseFloat(command.split(',')[1]);
}

describe('D3Funnel', function () {
	beforeEach(function (done) {
		done();
	});

	describe('constructor', function () {
		it('should instantiate without error', function () {
			new D3Funnel('#funnel');
		});
	});

	describe('methods', function () {
		describe('draw', function () {
			it('should draw a chart on the identified target', function () {
				getFunnel().draw(getBasicData(), {});

				assert.equal(1, getSvg()[0].length);
			});

			it('should draw when second argument is missing', function () {
				getFunnel().draw(getBasicData());

				assert.equal(1, getSvg()[0].length);
			});

			it('should throw an exception on invalid data', function () {
{'fraction_non_alphanumeric': 0.17984432609586234, 'fraction_numerical': 0.013928717738631708, 'mean_word_length': 4.4630872483221475, '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': '93797', 'n_tokens_mistral': 875, 'n_tokens_neox': 760, 'n_words': 176}