<commit_before>/*
* Name :  BarChart.js
* Module : UnitTest
* Location : /frontend/test/unit/Model
*
* History :
* Version       Date        Programmer                  Description
* =================================================================================================
* 0.3.0			2015-05-18	<NAME>			Restructured test
*
* 0.2.3         2015-05-17  <NAME>   Fix code
*
* 0.2.2			2015-05-15	<NAME>	Fix test of Model::BarChart
*
* 0.2.1			2015-05-15	<NAME>	Fix methods test
*
* 0.2.0			2015-05-15	<NAME>	Add test of all the methods of LineChart classes
*
* 0.1.0			2015-05-15	<NAME>	Add test of Model::BarChart.js
*
* 0.0.1			2015-05-15	<NAME>	Initial code
* =================================================================================================
*
*/

describe('BarChart', function(){
	'use strict';

	var BarChart;
	var Graph;
	var Axis;
	var BarChartFlow;

	beforeEach(module('app'));

	beforeEach(inject(function(_BarChart_, $injector){
		BarChart = _BarChart_;
		Graph = $injector.get('Graph');
		Axis = $injector.get('Axis');
		BarChartFlow = $injector.get('BarChartFlow');
	}));

	describe('Constructor', function(){

		beforeEach(function(){
			BarChart = new BarChart();
		});

		afterEach(function(){
			BarChart = null;
		});

		it('BarChart created', function(){
			expect(BarChart).toBeDefined();
		});
		it('graph created with the correct axisX', function(){
			expect(BarChart.getX()).toEqual(null);
		});
		it('graph created with the correct axisY', function(){
			expect(BarChart.getY()).toEqual(null);
		});
		it('graph created with the correct barOrientation', function(){
			expect(BarChart.getBarOrientation()).toEqual('vertical');
		});
		it('graph created with the correct background', function(){
			expect(BarChart.getBackground()).toEqual('#FFF');
		});
		it('graph created with the correct sortable', function(){
			expect(BarChart.getSortable()).toEqual(true);
		});
		it('graph created with the correct barsGrouping', function(){
			expect(BarChart.getBarsGrouping()).toEqual('grouped');
		});
		it('graph created with the correct flow', function(){
			expect(BarChart.getFlowList().length).toEqual(0);
		});

	});

	describe('Constructor', function(){

		var json = {
			'title' : 'graficonuovo',
			'height' : 400,
			'width' : 400,
			'enabledLegend' : false,
			'horizontalGrid' : false,
			'verticalGrid' : false,
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'vertical',
			'background' : '#F0F',
			'sortable' : false,
			'barsGrouping' : 'stacked',
			'flows' : [{},{},{}]
		};

		beforeEach(function(){
			BarChart = new BarChart(json);
		});

		afterEach(function(){
			BarChart = null;
		});		

		it('BarChart created', function(){
			expect(BarChart).toBeDefined();
		});
		it('graph Constructor called', function(){
			expect(BarChart.parent.constructor.call).toHaveBeenCalledWith(this, json);
		});
		it('graph created with the correct axisX', function(){
			expect(BarChart.getX()).toEqual({});
		});
		it('graph created with the correct axisY', function(){
			expect(BarChart.getY()).toEqual({});
		});
		it('graph created with the correct barOrientation', function(){
			expect(BarChart.getBarOrientation()).toEqual('vertical');
		});
		it('graph created with the correct background', function(){
			expect(BarChart.getBackground()).toEqual('#F0F');
		});
		it('graph created with the correct sortable', function(){
			expect(BarChart.getSortable()).toEqual(false);
		});
		it('graph created with the correct barsGrouping', function(){
			expect(BarChart.getBarsGrouping()).toEqual('stacked');
		});
		it('graph created with the correct flow', function(){
			expect(BarChart.addFlow.calls.count()).toEqual(3);
		});

	});

	/*describe('split', function(){
		var res;
		var json = {};
		var json1 = json;
		json = json1;
		json = {
			'title' : 'grafico',
			'height' : 300,
			'width' : 300,
			'enabledLegend' : true,
			'legend' : {},
			'horizontalGrid' : true,
			'verticalGrid' : true,
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'horizontal',
			'background' : '#FFF',
			'sortable' : false,
			'barsGrouping' : 'stacked'
		};
		var g = {
			'title' : 'grafico',
			'height' : 300,
			'width' : 300,
			'enabledLegend' : true,
			'legend' : {},
			'horizontalGrid' : true,
			'verticalGrid' : true
		};
		var b = {
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'horizontal',
			'background' : '#FFF',
			'sortable' : false,
			'barsGrouping' : 'stacked'
		};

		beforeEach(function(){
			res = BarChart.Test('split(json)');
		});

		it('json splitted in the correct way', function(){
			expect(res.graphJson).toEqual(g);
			expect(res.barJson).toEqual(b);
		});

	});*/

	describe('updateParameters', function(){
		var json = {
			'title' : 'graficonuovo',
			'height' : 400,
			'width' : 400,
			'enabledLegend' : false,
			'horizontalGrid' : false,
			'verticalGrid' : false,
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'vertical',
			'background' : '#F0F',
			'sortable' : false,
			'barsGrouping' : 'stacked',
			'flows' : [{},{},{}]
		};
		/*var gJson = {
			'title' : 'graficonuovo',
			'height' : 400,
			'width' : 400,
			'enabledLegend' : false,
			'horizontalGrid' : false,
			'verticalGrid' : false,
		};*/

		beforeEach(function(){
			BarChart = new BarChart();
			BarChart = BarChart.updateParameters(json);
		});

		afterEach(function(){
			BarChart = null;
		});	

		it('BarChart created', function(){
			expect(BarChart).toBeDefined();
		});

		/*it('graph updateParameters called with the correct parameters', function(){
			expect(BarChart.parent.updateParameters.call).toHaveBeenCalledWith(gJson);
		});*/
		it('graph updated with the correct axisX', function(){
			expect(BarChart.getX()).toEqual({});
		});
		it('graph updated with the correct axisY', function(){
			expect(BarChart.getY()).toEqual({});
		});
		it('graph updated with the correct barOrientation', function(){
			expect(BarChart.getBarOrientation()).toEqual('vertical');
		});
		it('graph updated with the correct background', function(){
			expect(BarChart.getBackground()).toEqual('#F0F');
		});
		it('graph updated with the correct sortable', function(){
			expect(BarChart.getSortable()).toEqual(false);
		});
		it('graph updated with the correct barsGrouping', function(){
			expect(BarChart.getBarsGrouping()).toEqual('stacked');
		});
		it('graph updated with the correct flow', function(){
			expect(BarChart.addFlow.calls.count()).toEqual(3);
		});
		
	});
	
	describe('addFlow', function(){

		var json = {
			'ID' : 	'flusso1'
		};

		beforeEach(function(){
			var newflow = BarChartFlow({});
			BarChart = new BarChart();
			BarChart = BarChart.addflow(json.ID, newflow);
		});

		afterEach(function(){
			BarChart = null;
		});	

		it('graph addFlow called with the correct parameters', function(){
			expect(BarChart.parent.addFlow.call).toHaveBeenCalledWith(this, json.ID, newflow);<commit_msg>fix test<commit_after>/*
* Name :  BarChart.js
* Module : UnitTest
* Location : /frontend/test/unit/Model
*
* History :
* Version       Date        Programmer                  Description
* =================================================================================================
* 0.3.0			2015-05-18	<NAME>			Restructured test
*
* 0.2.3         2015-05-17  <NAME>   Fix code
*
* 0.2.2			2015-05-15	<NAME>	Fix test of Model::BarChart
*
* 0.2.1			2015-05-15	<NAME>	Fix methods test
*
* 0.2.0			2015-05-15	<NAME>	Add test of all the methods of LineChart classes
*
* 0.1.0			2015-05-15	<NAME>	Add test of Model::BarChart.js
*
* 0.0.1			2015-05-15	<NAME>	Initial code
* =================================================================================================
*
*/

describe('BarChart', function(){
	'use strict';

	var BarChart;
	var Graph;
	var Axis;
	var BarChartFlow;

	beforeEach(module('app'));

	beforeEach(inject(function(_BarChart_, $injector){
		BarChart = _BarChart_;
		Graph = $injector.get('Graph');
		Axis = $injector.get('Axis');
		BarChartFlow = $injector.get('BarChartFlow');
	}));

	describe('Constructor', function(){

		beforeEach(function(){
			BarChart = new BarChart();
			console.log(BarChart.protoype.toString());
		});

		afterEach(function(){
			BarChart = null;
		});

		it('BarChart created', function(){
			expect(BarChart).toBeDefined();
		});
		it('graph created with the correct axisX', function(){
			expect(BarChart.getX()).toEqual(null);
		});
		it('graph created with the correct axisY', function(){
			expect(BarChart.getY()).toEqual(null);
		});
		it('graph created with the correct barOrientation', function(){
			expect(BarChart.getBarOrientation()).toEqual('vertical');
		});
		it('graph created with the correct background', function(){
			expect(BarChart.getBackground()).toEqual('#FFF');
		});
		it('graph created with the correct sortable', function(){
			expect(BarChart.getSortable()).toEqual(true);
		});
		it('graph created with the correct barsGrouping', function(){
			expect(BarChart.getBarsGrouping()).toEqual('grouped');
		});
		it('graph created with the correct flow', function(){
			expect(BarChart.getFlowList().length).toEqual(0);
		});

	});

	describe('Constructor', function(){

		var json = {
			'title' : 'graficonuovo',
			'height' : 400,
			'width' : 400,
			'enabledLegend' : false,
			'horizontalGrid' : false,
			'verticalGrid' : false,
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'vertical',
			'background' : '#F0F',
			'sortable' : false,
			'barsGrouping' : 'stacked',
			'flows' : [{},{},{}]
		};

		beforeEach(function(){
			BarChart = new BarChart(json);
		});

		afterEach(function(){
			BarChart = null;
		});		

		it('BarChart created', function(){
			expect(BarChart).toBeDefined();
		});
		it('graph Constructor called', function(){
			expect(BarChart.parent.constructor.call).toHaveBeenCalledWith(this, json);
		});
		it('graph created with the correct axisX', function(){
			expect(BarChart.getX()).toEqual({});
		});
		it('graph created with the correct axisY', function(){
			expect(BarChart.getY()).toEqual({});
		});
		it('graph created with the correct barOrientation', function(){
			expect(BarChart.getBarOrientation()).toEqual('vertical');
		});
		it('graph created with the correct background', function(){
			expect(BarChart.getBackground()).toEqual('#F0F');
		});
		it('graph created with the correct sortable', function(){
			expect(BarChart.getSortable()).toEqual(false);
		});
		it('graph created with the correct barsGrouping', function(){
			expect(BarChart.getBarsGrouping()).toEqual('stacked');
		});
		it('graph created with the correct flow', function(){
			expect(BarChart.addFlow.calls.count()).toEqual(3);
		});

	});

	/*describe('split', function(){
		var res;
		var json = {};
		var json1 = json;
		json = json1;
		json = {
			'title' : 'grafico',
			'height' : 300,
			'width' : 300,
			'enabledLegend' : true,
			'legend' : {},
			'horizontalGrid' : true,
			'verticalGrid' : true,
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'horizontal',
			'background' : '#FFF',
			'sortable' : false,
			'barsGrouping' : 'stacked'
		};
		var g = {
			'title' : 'grafico',
			'height' : 300,
			'width' : 300,
			'enabledLegend' : true,
			'legend' : {},
			'horizontalGrid' : true,
			'verticalGrid' : true
		};
		var b = {
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'horizontal',
			'background' : '#FFF',
			'sortable' : false,
			'barsGrouping' : 'stacked'
		};

		beforeEach(function(){
			res = BarChart.Test('split(json)');
		});

		it('json splitted in the correct way', function(){
			expect(res.graphJson).toEqual(g);
			expect(res.barJson).toEqual(b);
		});

	});*/

	describe('updateParameters', function(){
		var json = {
			'title' : 'graficonuovo',
			'height' : 400,
			'width' : 400,
			'enabledLegend' : false,
			'horizontalGrid' : false,
			'verticalGrid' : false,
			'axisX' : {},
			'axisY' : {},
			'barOrientation' : 'vertical',
			'background' : '#F0F',
			'sortable' : false,
			'barsGrouping' : 'stacked',
			'flows' : [{},{},{}]
		};
		/*var gJson = {
			'title' : 'graficonuovo',
			'height' : 400,
			'width' : 400,
			'enabledLegend' : false,
			'horizontalGrid' : false,
			'verticalGrid' : false,
		};*/

		beforeEach(function(){
			BarChart = new BarChart();
			BarChart = BarChart.updateParameters(json);
		});

		afterEach(function(){
			BarChart = null;
		});	

		it('BarChart created', function(){
			expect(BarChart).toBeDefined();
		});

		/*it('graph updateParameters called with the correct parameters', function(){
			expect(BarChart.parent.updateParameters.call).toHaveBeenCalledWith(gJson);
		});*/
		it('graph updated with the correct axisX', function(){
			expect(BarChart.getX()).toEqual({});
		});
		it('graph updated with the correct axisY', function(){
			expect(BarChart.getY()).toEqual({});
		});
		it('graph updated with the correct barOrientation', function(){
			expect(BarChart.getBarOrientation()).toEqual('vertical');
		});
		it('graph updated with the correct background', function(){
			expect(BarChart.getBackground()).toEqual('#F0F');
		});
		it('graph updated with the correct sortable', function(){
			expect(BarChart.getSortable()).toEqual(false);
		});
		it('graph updated with the correct barsGrouping', function(){
			expect(BarChart.getBarsGrouping()).toEqual('stacked');
		});
		it('graph updated with the correct flow', function(){
			expect(BarChart.addFlow.calls.count()).toEqual(3);
		});
		
	});
	
	describe('addFlow', function(){

		var json = {
			'ID' : 	'flusso1'
		};
		var newflow;

		beforeEach(function(){
			newflow = BarChartFlow({});
			BarChart = new BarChart();
			BarChart = BarChart.addflow(json.ID, newflow);
		});

		afterEach(function(){
			BarChart = null;
		});	

		it('graph addFlow called with the correct parameters', function(){
			expect(BarChart.parent.addFlow.call).toHaveBeenCalledWith(this, json.ID, newflow);
{'fraction_non_alphanumeric': 0.20537773933102652, 'fraction_numerical': 0.016868512110726645, 'mean_word_length': 4.033744557329463, 'pattern_counts': {'":': 0, '<': 17, '<?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': '2120654', 'n_tokens_mistral': 5306, 'n_tokens_neox': 4489, 'n_words': 950}