text: import FusionCharts from"../../../../fusioncharts/core";import chartType from"./index";import chartValidator from"../../../../../smoke-test/test-sanity/area2d.sanity";import ignoreCaseExt from"../../../../fc-features/src/ignore-case-ext";import{setup,getSVG,initDimensions,resizeDimensions,CONTAINER_ID}from"../../../../../smoke-test/test-sanity/utility";import{extend2}from"../../../../fc-core/src/lib/";import CommonTests from"../../../../../smoke-test/test-sanity/common.sanity";import*as chartData from"../../../../../smoke-test/test-data/data-by-chart";FusionCharts.addDep(chartType);FusionCharts.addDep(ignoreCaseExt);var svgElement,chartName=chartType.getName(),chartID=chartName.toLowerCase(),doc=window.document;describe("Running common chart tests for "+chartName,function(){var chart={type:chartID,renderAt:CONTAINER_ID,width:initDimensions.width,height:initDimensions.height,dataFormat:"json",dataSource:{}},config={chartID:chartID,chart:chart,document:doc,chartWrapperId:CONTAINER_ID};CommonTests.forEach(function(test){var itArr;if(test.name&&test.run){it(test.name,function(done){test.run(config,function(result){expect(result).toBe(true);done()})})}else if(test.iterator){itArr=test.iterator(chart);itArr.forEach(function(subTest){it(subTest.name,function(done){subTest.run(config,function(result){expect(result).toBe(true);done()})})})}})});describe("Chart basic testing: "+chartName,function(){var chart,chartObj,itResize,renderData=chartValidator.BASIC.newChart,updateData=chartValidator.BASIC.updateChart;chart={type:chartID,renderAt:CONTAINER_ID};extend2(chart,renderData);chart.dataSource=chart.dataSource?chart.dataSource:chartData[chartID]["default"];chart.dataSource.chart.animation="0";beforeEach(function(){chartObj=setup(FusionCharts,chart)});afterEach(function(){if(chartObj&&!chartObj.disposed)chartObj.dispose()});it("Rendered chart validation passes",function(done){expect(chartObj).toBeDefined();var renderComplete=function renderComplete(){var response=chartValidator.BASIC.validate(chartObj);expect(response.flag).toBe(true,response.messages.join(" && "));done()};chartObj.render();chartObj.addEventListener("renderComplete",renderComplete)});it("Chart update passes",function(done){expect(chartObj).toBeDefined();var called=0;var renderComplete=function renderComplete(){if(called===0){called++;chartObj.setChartData(updateData||chart.dataSource,"json")}else if(called===1){var response=chartValidator.BASIC.updateValidate(chartObj);expect(response.flag).toBe(true,response.messages.join(" && "));done()}};chartObj.addEventListener("renderComplete",renderComplete);chartObj.render()});itResize=function itResize(resizeDimensions){it("Chart resize passes for "+resizeDimensions.width+" x "+resizeDimensions.height,function(done){expect(chartObj).toBeDefined();var renderComplete=function renderComplete(){var response=chartValidator.BASIC.resizeValidate(chartObj);expect(response.flag).toBe(true,response.messages.join(" && "));done()};chartObj.addEventListener("renderComplete",renderComplete);chartObj.render(function(){chartObj.resizeTo(resizeDimensions.width,resizeDimensions.height)})})};for(var index=0;index<resizeDimensions.length;index++){itResize(resizeDimensions[index])}});describe("Chart EI testing: "+chartType.getName(),function(){var chart,chartObj,eiMethods,renderData=chartValidator.EI.newChart;chart={type:chartID,renderAt:CONTAINER_ID};extend2(chart,renderData);chart.dataSource=chart.dataSource?chart.dataSource:chartData[chartID]["default"];chart.dataSource.chart.animation="0";beforeEach(function(){chartObj=setup(FusionCharts,chart)});afterEach(function(){if(chartObj&&!chartObj.disposed)chartObj.dispose()});eiMethods=function eiMethods(methodObj){it(methodObj.name,function(done){expect(chartObj).toBeDefined();var renderComplete=function renderComplete(){svgElement=getSVG(chartObj);methodObj.fn(svgElement,chartObj,function(result){expect(result).toBe(true);done()})};chartObj.addEventListener("renderComplete",renderComplete);chartObj.render()})};for(var key in chartValidator.EI.methods){if(chartValidator.EI.methods.hasOwnProperty(key)){eiMethods(chartValidator.EI.methods[key])}}});describe("Testing inheritPlotBorderColor for: "+chartName,function(){var chartObj,areaPaths,dataSource={chart:{caption:"Monthly Revenue",xaxisname:"Month",yaxisname:"Revenue",numberprefix:"$",showvalues:"1",inheritplotbordercolor:"1",useplotgradientcolor:"0"},data:[{label:"Jan",value:"420000"},{label:"Feb",value:"910000"},{label:"Mar",value:"720000"},{label:"Apr",value:"550000"},{label:"May",value:"810000"},{label:"Jun",value:"510000"},{label:"Jul",value:"680000"},{label:"Aug",value:"620000"},{label:"Sep",value:"610000"},{label:"Oct",value:"490000"},{label:"Nov",value:"530000"},{label:"Dec",value:"330000"}]},chartData={type:chartID,renderAt:CONTAINER_ID,width:initDimensions.width,height:initDimensions.height,dataFormat:"json",dataSource:dataSource};beforeEach(function(){chartObj=setup(FusionCharts,chartData)});afterEach(function(){if(chartObj&&!chartObj.disposed)chartObj.dispose()});it("When inheritplotborder color is enabled border and plot color should be same",function(done){var renderComplete=function renderComplete(){areaPaths=document.querySelector('[class*="-common-elems-group"]');var borderColor=areaPaths.children[1].attributes.stroke.value,plotColor=areaPaths.children[0].attributes.fill.value;expect(borderColor).toEqual(plotColor);done()};chartObj.render();chartObj.addEventListener("renderComplete",renderComplete)});it("When inheritplotborder color is disabled border and plot color shouldn't be same",function(done){chartObj.setChartAttribute("inheritplotbordercolor","0");var renderComplete=function renderComplete(){areaPaths=document.querySelector('[class*="-common-elems-group"]');var borderColor=areaPaths.children[1].attributes.stroke.value,plotColor=areaPaths.children[0].attributes.fill.value;expect(borderColor).not.toEqual(plotColor);done()};chartObj.render();chartObj.addEventListener("renderComplete",renderComplete)})});describe("area2d showValues testing",function(){var chartObj,renderInfo={type:"area2d",renderAt:CONTAINER_ID,width:"600",height:"350",dataFormat:"json"},data={chart:{caption:"Monthly",xaxisname:"Month",yaxisname:"Revenue",numberprefix:"$",plottooltext:"<div>br is applied</div>",drawcrossline:"1",showValues:"1"},data:[{label:"Jan",value:"420000",showValue:"1"},{label:"Feb",value:"910000",showValue:"0"},{label:"Mar",value:"720000",minPlotHeightForValue:"170"},{label:"Apr",value:"550000",minPlotHeightForValue:"150"},{label:"May",value:"810000"},{label:"Jun",value:"510000"},{label:"Jul",value:"680000"},{label:"Aug",value:"620000"},{label:"Sep",value:"610000"},{label:"Oct",value:"490000"},{label:"Nov",value:"530000"},{label:"Dec",value:"330000"}]};beforeEach(function(){renderInfo.dataSource=data;chartObj=setup(FusionCharts,renderInfo)});afterEach(function(){chartObj&&!chartObj.disposed&&chartObj.dispose()});it("chart dataplot will appear when plotLavel ShowValue is set one",function(done){chartObj.addEventListener("renderComplete",function(){var dataLabelObj=document.querySelectorAll('[class*="label-group fusioncharts-datalabels"]')[0].children[0];if(dataLabelObj.innerHTML==="$420K"){done()}});chartObj.render()});it("chart dataplot will not appear when plotLavel ShowValue is set zero",function(done){chartObj.addEventListener("renderComplete",function(){var dataLabelObj=document.querySelectorAll('[class*="label-group fusioncharts-datalabels"]')[0].children[1];if(dataLabelObj.innerHTML!=="$910k"){done()}});chartObj.render()})});