text: import FusionCharts from"../../../../fusioncharts/core";import chartType from"./index";import chartValidator from"../../../../../smoke-test/test-sanity/dragarea.sanity";import ignoreCaseExt from"../../../../fc-features/src/ignore-case-ext";import inputAdapter from"../../../../fc-features/src/input-ext";import XML from"../../../../fc-features/src/xml-transcoder";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);FusionCharts.addDep(inputAdapter);FusionCharts.addDep(XML);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])}}});