text: import Axis from"./axis";import OriginalScale from"./../../../../fc-utils/src/scales/time-bin";import OriginalLinearScale from"./../../../../fc-utils/src/scales/linear";import timeConverter from"./../../../../fc-utils/src/time-converter";import SmartLabelManager from"../../../../fc-core/src/_internal/vendors/fusioncharts-smartlabel/src/SmartlabelManager";var Scale=function(){function Scale(){this._timeFormat={major:"day",minor:"hour"};this._tickType=["minor","minor","minor","major","minor","minor","minor"];this.formatters={millisecond:timeConverter.formatter(".%L"),second:timeConverter.formatter(":%S"),minute:timeConverter.formatter("%I:%M"),hour:timeConverter.formatter("%I %p"),day:timeConverter.formatter("%b %d"),week:timeConverter.formatter("%b %d"),month:timeConverter.formatter("%B"),year:timeConverter.formatter("%Y")}}var _proto=Scale.prototype;_proto.getRangeValue=function getRangeValue(d){return Number(d)};_proto.ticks=function ticks(){return[new Date("Sat Feb 01 2014 06:00:00 GMT+0530"),new Date("Sat Feb 01 2014 12:00:00 GMT+0530"),new Date("Sat Feb 01 2014 18:00:00 GMT+0530"),new Date("Sun Feb 02 2014 00:00:00 GMT+0530"),new Date("Sun Feb 02 2014 06:00:00 GMT+0530"),new Date("Sun Feb 02 2014 12:00:00 GMT+0530"),new Date("Sun Feb 02 2014 18:00:00 GMT+0530")]};_proto.setDomain=function setDomain(){};_proto.getDomain=function getDomain(){return[new Date("Sat Feb 01 2014 05:30:00 GMT+0530"),new Date("Sun Feb 02 2014 20:30:00 GMT+0530")]};_proto.tickFormat=function tickFormat(){var _this=this;return function(d,type){return _this.formatters[type].format(d)}};_proto.getRange=function getRange(){return[49.2314453125,584]};_proto.copy=function copy(){return this};return Scale}();describe("AX_TS_1: Verify axis is placed in position",function(){var axis,graphicalElements={};beforeEach(function(){axis=new Axis;graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis._env.chart={config:{}};axis.config.values=[];axis.__setDefaultConfig()});afterEach(function(){axis=undefined;graphicalElements={}});describe("Test for Vertical Axis",function(){it("vertical left axis translation",function(){axis.configure({orientation:"left"});axis.setAxisDimension(40);expect(axis.config.groupTranslation).toBe("t40,0")});it("vertical left axis orientation",function(){axis.configure({orientation:"left"});axis.setAxisDimension(40);expect(axis.config.k).toBe(-1)});it("vertical right axis translation",function(){axis.configure({orientation:"right"});axis.setAxisDimension(40);expect(axis.config.groupTranslation).toBe("t40,0")});it("vertical right axis orientation",function(){axis.configure({orientation:"right"});axis.setAxisDimension(40);expect(axis.config.k).toBe(1)})});describe("Test for Horizontal Axis",function(){it("horizontal top axis translation",function(){axis.configure({orientation:"top"});axis.setAxisDimension(40);expect(axis.config.groupTranslation).toBe("t0,40")});it("horizontal top axis orientation",function(){axis.configure({orientation:"top"});axis.setAxisDimension(40);expect(axis.config.k).toBe(-1)});it("horizontal bottom axis translation",function(){axis.configure({orientation:"bottom"});axis.setAxisDimension(40);expect(axis.config.groupTranslation).toBe("t0,40")});it("horizontal bottom axis orientation",function(){axis.configure({orientation:"bottom"});axis.setAxisDimension(40);expect(axis.config.k).toBe(1)})});describe("Test for final attr sent for drawing element: Horizontal Axis",function(){it("horizontal top axis attr",function(){axis.configure({orientation:"top"});axis.setAxisDimension(40);axis.draw();expect(axis.getGraphicalElement("axisGroup").attr.name).toBe("axis-top");expect(axis.getGraphicalElement("axisGroup").attr.transform).toBe("t0,40")});it("horizontal bottom axis attr",function(){axis.configure({orientation:"bottom"});axis.setAxisDimension(40);axis.draw();expect(axis.getGraphicalElement("axisGroup").attr.name).toBe("axis-bottom");expect(axis.getGraphicalElement("axisGroup").attr.transform).toBe("t0,40")})});describe("Test for final attr sent for drawing element: Vertical Axis",function(){it("vertical left axis attr",function(){axis.configure({orientation:"left"});axis.setAxisDimension(40);axis.draw();expect(axis.getGraphicalElement("axisGroup").attr.name).toBe("axis-left");expect(axis.getGraphicalElement("axisGroup").attr.transform).toBe("t40,0")});it("vertical right axis attr",function(){axis.configure({orientation:"right"});axis.setAxisDimension(40);axis.draw();expect(axis.getGraphicalElement("axisGroup").attr.name).toBe("axis-right");expect(axis.getGraphicalElement("axisGroup").attr.transform).toBe("t40,0")})})});describe("AX_TS_2: Verify the length of the ticks",function(){var axis,scale,typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,139135284e4];beforeEach(function(){axis=new Axis;scale=new Scale;scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:new SmartLabelManager(document.body||document.getElementsByTagName("body")[0])};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_13: The length of all minor ticks should be equal",function(){axis.placeAxis();axis.draw();var ticks=axis.getGraphicalElementByType("tick");for(var i=0;i<scale._tickType.length;++i){if(scale._tickType[i]==="minor"){expect(ticks[i].attr.path).toBe("M0,0L0,4.800000000000001")}}});it("AX_TC_14: The length of all major ticks should be equal",function(){axis.placeAxis();axis.draw();var ticks=axis.getGraphicalElementByType("tick");for(var i=0;i<scale._tickType.length;++i){if(scale._tickType[i]==="major"){expect(ticks[i].attr.path).toBe("M0,0L0,12")}}});it("AX_TC_15: The length of major tick must be greater than minor tick",function(){axis.placeAxis();axis.draw();var minorTickIndex=scale._tickType.indexOf("minor"),ticks=axis.getGraphicalElementByType("tick"),minorTickLen=+ticks[minorTickIndex].attr.path.split(",")[2];for(var i=0;i<ticks.length;++i){if(scale._tickType[i]==="major"){expect(+ticks[i].attr.path.split(",")[2]).toBeGreaterThan(minorTickLen)}}});it("AX_TC_16: Validate the ticks length when negative value is provided",function(){axis.configure({scale:scale,orientation:"bottom",tickSize:-12});axis.placeAxis();axis.draw();var ticks=axis.getGraphicalElementByType("tick");for(var i=0;i<scale._tickType.length;++i){expect(+ticks[i].attr.path.split(",")[2]).toBeGreaterThan(0)}})});describe("AX_TS_4: Verify the alignment of the ticks",function(){var axis,scale,typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,139135284e4];beforeEach(function(){axis=new Axis;scale=new Scale;scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:new SmartLabelManager(document.body||document.getElementsByTagName("body")[0])};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_19: All the ticks must be drawn from a fixed height (x-axis line)",function(){axis.placeAxis();axis.draw();var ticks=axis.getGraphicalElementByType("tick"),tickGroups=axis.getGraphicalElementByType("tick-group");for(var i=0;i<tickGroups.length;++i){expect(+tickGroups[i].attr.transform.split(",")[1]).toBe(0);expect(ticks[i].attr.path.split(",")[0]).toBe("M0");expect(ticks[i].attr.path.split(",")[1]).toBe("0L0")}});it("AX_TC_20: The space between any two consecutive ticks must equal",function(){axis.placeAxis();axis.draw();var tickGroups=axis.getGraphicalElementByType("tick-group"),getXTranslation=function getXTranslation(transformString){return+transformString.split(",")[0].substring(1)},differenceWidth=getXTranslation(tickGroups[1].attr.transform)-getXTranslation(tickGroups[0].attr.transform);for(var i=1;i<tickGroups.length;++i){expect(getXTranslation(tickGroups[i].attr.transform)-getXTranslation(tickGroups[i-1].attr.transform)).toBe(differenceWidth)}})});describe("AX_TS_7: Verify that minor labels are not overlapping",function(){var axis,scale,getXTranslation=function getXTranslation(transformString){return+transformString.split(",")[0].substring(1)},smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,13913532e5];beforeEach(function(){axis=new Axis;scale=new OriginalScale;scale.setRange([49.2314453125,584]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_27: Consecutive minor labels should not overlap with each other when labels are small",function(){axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(scale._tickType[i]==="minor"&&labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos})}}for(var _i=0;_i<ticksArr.length-1;++_i){expect(ticksArr[_i].end).toBeLessThan(ticksArr[_i+1].start)}});it("AX_TC_48: Consecutive minor labels should not overlap with each other when labels are large",function(){axis.config.baseStyle={fontFamily:"sans-serif",fontSize:72+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(scale._tickType[i]==="minor"&&labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos})}}for(var _i2=0;_i2<ticksArr.length-1;++_i2){expect(ticksArr[_i2].end).toBeLessThan(ticksArr[_i2+1].start)}})});describe("AX_TS_8: Verify that major labels are not overlapping",function(){var axis,scale,getXTranslation=function getXTranslation(transformString){return+transformString.split(",")[0].substring(1)},smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,13913532e5];beforeEach(function(){axis=new Axis;scale=new OriginalScale;scale.setRange([49.2314453125,584]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_28: Consecutive major labels should not overlap with each other when labels are small",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(scale._tickType[i]==="major"&&labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos})}}for(var _i3=0;_i3<ticksArr.length-1;++_i3){expect(ticksArr[_i3].end).toBeLessThan(ticksArr[_i3+1].start)}});it("AX_TC_49: Consecutive major labels should not overlap with each other when labels are large",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:100+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(scale._tickType[i]==="major"&&labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos})}}for(var _i4=0;_i4<ticksArr.length-1;++_i4){expect(ticksArr[_i4].end).toBeLessThan(ticksArr[_i4+1].start)}})});describe("AX_TS_9: Verify that major label and minor labels are not overlapping",function(){var axis,scale,getXTranslation=function getXTranslation(transformString){return+transformString.split(",")[0].substring(1)},smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,13913532e5];beforeEach(function(){axis=new Axis;scale=new OriginalScale;scale.setRange([49.2314453125,584]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_29: Major label should not overlap with minor labels when label size is small",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:20+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos})}}for(var _i5=0;_i5<ticksArr.length-1;++_i5){expect(ticksArr[_i5].end).toBeLessThan(ticksArr[_i5+1].start)}});it("AX_TC_30: Major label should not overlap with minor labels when label size is large",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:72+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos})}}for(var _i6=0;_i6<ticksArr.length-1;++_i6){expect(ticksArr[_i6].end).toBeLessThan(ticksArr[_i6+1].start)}})});describe("AX_TS_10: Verify alignment of the labels",function(){var axis,scale,smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,13913532e5];beforeEach(function(){axis=new Axis;scale=new OriginalScale;scale.setRange([49.2314453125,584]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_31: Major labels must be aligned middle to its tick",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:20+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickTypesArr=scale._tickType;for(var i=0;i<tickTypesArr.length;++i){if(tickTypesArr[i]==="major"){expect(labels[i].attr["text-anchor"]).toBe("middle");expect(labels[i].attr.x).toBe(0)}}});it("AX_TC_32: Minor labels must be aligned middle to its tick",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:20+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickTypesArr=scale._tickType;for(var i=0;i<tickTypesArr.length;++i){if(tickTypesArr[i]==="minor"){expect(labels[i].attr["text-anchor"]).toBe("middle");expect(labels[i].attr.x).toBe(0)}}});it("AX_TC_33: Context labels must be aligned middle to its tick",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:20+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickTypesArr=scale._tickType;for(var i=0;i<tickTypesArr.length;++i){if(tickTypesArr[i]==="context"){expect(labels[i].attr["text-anchor"]).toBe("middle");expect(labels[i].attr.x).toBe(0)}}})});describe("AX_TS_11: Verify the ticks and labels are not overlapping",function(){var axis,scale,smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,13913532e5];beforeEach(function(){axis=new Axis;scale=new OriginalScale;scale.setRange([49.2314453125,584]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_34: A major label must not overlap with the tick of major label",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:20+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),ticks=axis.getGraphicalElementByType("tick"),tickTypesArr=scale._tickType;for(var i=0;i<tickTypesArr.length;++i){if(tickTypesArr[i]==="major"){expect(labels[i].attr.y).toBeGreaterThan(Number(ticks[i].attr.path.split(",")[2]))}}});it("AX_TC_35: A minor label must not overlap with the tick of minor label",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:20+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),ticks=axis.getGraphicalElementByType("tick"),tickTypesArr=scale._tickType;for(var i=0;i<tickTypesArr.length;++i){if(tickTypesArr[i]==="minor"){expect(labels[i].attr.y).toBeGreaterThan(Number(ticks[i].attr.path.split(",")[2]))}}});it("AX_TC_36: A context label must not overlap with tick of context label",function(){scale.setDomain([13912128e5,13912199e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:20+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),ticks=axis.getGraphicalElementByType("tick"),tickTypesArr=scale._tickType;for(var i=0;i<tickTypesArr.length;++i){if(tickTypesArr[i]==="context"){expect(labels[i].attr.y).toBeGreaterThan(Number(ticks[i].attr.path.split(",")[2]))}}})});describe("AX_TS_12: Verify the context labels are not overlapping",function(){var axis,scale,getXTranslation=function getXTranslation(transformString){return+transformString.split(",")[0].substring(1)},smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[13912128e5,13913532e5];beforeEach(function(){axis=new Axis;scale=new OriginalScale;scale.setRange([49.2314453125,584]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,orientation:"bottom"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_37: Consecutive context label must not overlap with each other",function(){scale.setDomain([9697329e5,9697401e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(scale._tickType[i]==="context"&&labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos})}}for(var _i7=0;_i7<ticksArr.length-1;++_i7){expect(ticksArr[_i7].end).toBeLessThan(ticksArr[_i7+1].start)}});it("AX_TC_38: Context label must not overlap with major label above it",function(){scale.setDomain([9697329e5,9697401e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(scale._tickType[i]==="context"&&labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos,top:labels[i].attr.y})}}smartLabel.setStyle({fontSize:"12px"});for(var j=0;j<scale._tickType.length;++j){if(scale._tickType[j]==="major"){for(var _i8=0;_i8<ticksArr.length;++_i8){expect(ticksArr[_i8].top).toBeGreaterThan(smartLabel.getOriSize(labels[j].attr.text).height-6+labels[j].attr.y)}}}});it("AX_TC_39: Context label must not overlap with minor label",function(){scale.setDomain([9697329e5,9697401e5]);axis.config.baseStyle={fontFamily:"sans-serif",fontSize:30+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var labels=axis.getGraphicalElementByType("tick-label"),tickGroup=axis.getGraphicalElementByType("tick-group"),ticksArr=[],labelStartPos,labelWidth,labelEndPos;for(var i=0;i<tickGroup.length;++i){labelWidth=smartLabel.getSmartText(labels[i].attr.text||"").width;labelStartPos=getXTranslation(tickGroup[i].attr.transform)-labelWidth/2;labelEndPos=getXTranslation(tickGroup[i].attr.transform)+labelWidth/2;if(scale._tickType[i]==="context"&&labels[i].attr.text){ticksArr.push({start:labelStartPos,end:labelEndPos,top:labels[i].attr.y})}}smartLabel.setStyle({fontSize:"30px"});for(var j=0;j<scale._tickType.length;++j){if(scale._tickType[j]==="minor"){for(var _i9=0;_i9<ticksArr.length;++_i9){if(getXTranslation(tickGroup[j].attr.transform)-smartLabel.getOriSize(labels[j].attr.text).width>ticksArr[_i9].start&&getXTranslation(tickGroup[j].attr.transform)-smartLabel.getOriSize(labels[j].attr.text).width<ticksArr[_i9].end){expect(labels[j].attr.y+smartLabel.getOriSize(labels[j].attr.text).height).toBeLessThan(ticksArr[_i9].top)}}}}})});describe("AX_TS_13: Verify that axis name is not overlapping",function(){var axis,scale,smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[0,1202794];beforeEach(function(){axis=new Axis;scale=new OriginalLinearScale;scale.setRange([0,518.3685546875]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,title:"Testing the axis name",orientation:"left"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_40: Y-axis name should not overlap with labels",function(){axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();smartLabel.setStyle({fontSize:"12px"});var labels=axis.getGraphicalElementByType("tick-label"),axisName=axis.getGraphicalElement("axis-name").attr,axisNameStartPos=axisName.x,axisNameWidth=smartLabel.getOriSize(axisName.text).height,axisNameEndPos=axisNameStartPos+axisNameWidth,labelAttr,labelStartPos;for(var i=0;i<labels.length;++i){labelAttr=labels[i].attr;labelStartPos=-smartLabel.getOriSize(labelAttr.text).width+labelAttr.x;expect(axisNameEndPos<labelStartPos).toBeTruthy()}});it("AX_TC_41: Y-axis name should not overlap with ticks",function(){axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();smartLabel.setStyle({fontSize:"12px"});var ticks=axis.getGraphicalElementByType("tick"),axisName=axis.getGraphicalElement("axis-name").attr,axisNameStartPos=axisName.x,axisNameWidth=smartLabel.getOriSize(axisName.text).height,axisNameEndPos=axisNameStartPos+axisNameWidth,tickAttr,tickStartPos;for(var i=0;i<ticks.length;++i){tickAttr=ticks[i].attr;tickStartPos=Number(tickAttr.path.split("L")[1].split(",")[0]);expect(axisNameEndPos).toBeLessThan(tickStartPos)}});it("AX_TC_42: Y-axis name should not overlap with axis line",function(){axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();smartLabel.setStyle({fontSize:"12px"});var line=axis.getGraphicalElement("axis-line"),axisName=axis.getGraphicalElement("axis-name").attr,axisNameStartPos=axisName.x,axisNameWidth=smartLabel.getOriSize(axisName.text).height,axisNameEndPos=axisNameStartPos+axisNameWidth,linePath=line.attr.path,lineStartPos=linePath.split(" ")[1];expect(axisNameEndPos).toBeLessThan(lineStartPos)})});describe("AX_TS_14: Verify that axis-name doesn't take more space",function(){var axis,scale,smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[0,1202794];beforeEach(function(){axis=new Axis;scale=new OriginalLinearScale;scale.setRange([0,518.3685546875]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();axis.configure({scale:scale,title:"Testing the axis name",orientation:"left"});graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_43: Validate when font size is large enough to collide with axis labels",function(){axis.config.baseStyle={fontFamily:"sans-serif",fontSize:50+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();smartLabel.setStyle({fontSize:"50px"});var labels=axis.getGraphicalElementByType("tick-label"),axisName=axis.getGraphicalElement("axis-name").attr,axisNameStartPos=axisName.x,axisNameWidth=smartLabel.getOriSize(axisName.text).height,axisNameEndPos=axisNameStartPos+axisNameWidth,labelAttr,labelStartPos;smartLabel.setStyle({fontSize:"12px"});for(var i=0;i<labels.length;++i){labelAttr=labels[i].attr;labelStartPos=-smartLabel.getOriSize(labelAttr.text).width+labelAttr.x;expect(axisNameEndPos<labelStartPos).toBeTruthy()}});it("AX_TC_44: Validate when font size is small enough not to collide with axis labels",function(){axis.config.baseStyle={fontFamily:"sans-serif",fontSize:10+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();smartLabel.setStyle({fontSize:"10px"});var labels=axis.getGraphicalElementByType("tick-label"),axisName=axis.getGraphicalElement("axis-name").attr,axisNameStartPos=axisName.x,axisNameWidth=smartLabel.getOriSize(axisName.text).height,axisNameEndPos=axisNameStartPos+axisNameWidth,labelAttr,labelStartPos;smartLabel.setStyle({fontSize:"12px"});for(var i=0;i<labels.length;++i){labelAttr=labels[i].attr;labelStartPos=-smartLabel.getOriSize(labelAttr.text).width+labelAttr.x;expect(axisNameEndPos<labelStartPos).toBeTruthy()}})});describe("AX_TS_15: Verify that axis-name is visible",function(){var axis,scale,smartLabel=new SmartLabelManager(document.body||document.getElementsByTagName("body")[0]),typeRegex={tick:/tick-[0-9]+/gi,"tick-label":/tick-label-[0-9]+/gi,"tick-group":/tick-group-[0-9]+/gi},graphicalElements={},domain=[0,1202794];beforeEach(function(){axis=new Axis;scale=new OriginalLinearScale;scale.setRange([0,518.3685546875]);scale.setDomain(domain);axis._env={chart:{config:{}},smartLabel:smartLabel};axis.__setDefaultConfig();graphicalElements={};axis.addGraphicalElement=function(obj){graphicalElements[obj.id]=obj};axis.getGraphicalElement=function(id){return graphicalElements[id]};axis.getGraphicalElementByType=function(type){var keyArr=Object.keys(graphicalElements).filter(function(key){return typeRegex[type].test(key)}),typeArr=[];for(var i=0;i<keyArr.length;++i){typeArr.push(graphicalElements[keyArr[i]])}return typeArr}});afterEach(function(){axis=undefined;scale=undefined});it("AX_TC_45: To verify if it draws when axis name is very long enough to go outside the canvas",function(){axis.configure({scale:scale,title:"Testing the axis name which is long enough to go outside the canvas Testing the axis name which is long enough to go outside the canvas Testing the axis name which is long enough to go outside the canvas Testing the axis name which is long enough to go outside the canvas Testing the axis name which is long enough to go outside the canvas Testing the axis name which is long enough to go outside the canvas",orientation:"left"});axis.config.baseStyle={fontFamily:"sans-serif",fontSize:12+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();smartLabel.setStyle({fontSize:"12px"});var axisName=axis.getGraphicalElement("axis-name").attr,axisNameStartPos=axisName.y,axisNameHeight=smartLabel.getOriSize(axisName.text).width,axisNameEndPos=axisNameStartPos+axisNameHeight;expect(axisNameEndPos).toBeLessThan(518.3685546875)});it("AX_TC_46: To verify if it draws when axis name font is very large enough to go outside the canvas area",function(){axis.configure({scale:scale,title:"Testing the axis name",orientation:"left"});axis.config.baseStyle={fontFamily:"sans-serif",fontSize:70+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();smartLabel.setStyle({fontSize:"70px"});var axisName=axis.getGraphicalElement("axis-name").attr,axisNameStartPos=axisName.y,axisNameHeight=smartLabel.getOriSize(axisName.text).width,axisNameEndPos=axisNameStartPos+axisNameHeight;expect(axisNameEndPos).toBeLessThan(518.3685546875)});it("AX_TC_47: To verify if it draws when axis name contains special characters",function(){axis.configure({scale:scale,title:"¢∞§ ¶•§ ¢¶ ¡ ¶• ºººª",orientation:"left"});axis.config.baseStyle={fontFamily:"sans-serif",fontSize:10+"px",fontStyle:"normal",fontWeight:"normal"};axis.placeAxis();axis.draw();var axisName=axis.getGraphicalElement("axis-name").attr;expect(axisName.text).toBe("¢∞§ ¶•§ ¢¶ ¡ ¶• ºººª")})});