From: Evert Timberg Date: Wed, 16 Dec 2015 00:30:09 +0000 (-0500) Subject: Fix tests X-Git-Tag: 2.0.0-beta2~19^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=274897fc24151b9dfc67880d982dd405c5e28752;p=thirdparty%2FChart.js.git Fix tests --- diff --git a/test/scale.linear.tests.js b/test/scale.linear.tests.js index c773ef448..ef1b2cbb9 100644 --- a/test/scale.linear.tests.js +++ b/test/scale.linear.tests.js @@ -406,7 +406,7 @@ describe('Linear Scale', function() { expect(scale.min).toBe(-1010); expect(scale.max).toBe(1010); expect(scale.ticks[0]).toBe(1010); - expect(scale.ticks[scale.ticks.length-1]).toBe(-1010); + expect(scale.ticks[scale.ticks.length - 1]).toBe(-1010); }); it('should forcibly include 0 in the range if the beginAtZero option is used', function() { @@ -1127,16 +1127,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 30.2] + "args": [25, 30.5] }, { "name": "lineTo", - "args": [30, 30.2] + "args": [30, 30.5] }, { "name": "moveTo", - "args": [30, 30.2] + "args": [30, 30.5] }, { "name": "lineTo", - "args": [130, 30.2] + "args": [130, 30.5] }, { "name": "stroke", "args": [] @@ -1145,7 +1145,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 29.7] + "args": [20, 30] }, { "name": "rotate", "args": [-0] @@ -1160,16 +1160,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 59.9] + "args": [25, 59.5] }, { "name": "lineTo", - "args": [30, 59.9] + "args": [30, 59.5] }, { "name": "moveTo", - "args": [30, 59.9] + "args": [30, 59.5] }, { "name": "lineTo", - "args": [130, 59.9] + "args": [130, 59.5] }, { "name": "stroke", "args": [] @@ -1178,7 +1178,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 59.4] + "args": [20, 59] }, { "name": "rotate", "args": [-0] @@ -1193,16 +1193,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 89.6] + "args": [25, 89.5] }, { "name": "lineTo", - "args": [30, 89.6] + "args": [30, 89.5] }, { "name": "moveTo", - "args": [30, 89.6] + "args": [30, 89.5] }, { "name": "lineTo", - "args": [130, 89.6] + "args": [130, 89.5] }, { "name": "stroke", "args": [] @@ -1211,7 +1211,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 89.1] + "args": [20, 89] }, { "name": "rotate", "args": [-0] @@ -1226,16 +1226,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 119.3] + "args": [25, 119.5] }, { "name": "lineTo", - "args": [30, 119.3] + "args": [30, 119.5] }, { "name": "moveTo", - "args": [30, 119.3] + "args": [30, 119.5] }, { "name": "lineTo", - "args": [130, 119.3] + "args": [130, 119.5] }, { "name": "stroke", "args": [] @@ -1244,7 +1244,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 118.8] + "args": [20, 119] }, { "name": "rotate", "args": [-0] @@ -1265,16 +1265,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 149] + "args": [25, 149.5] }, { "name": "lineTo", - "args": [30, 149] + "args": [30, 149.5] }, { "name": "moveTo", - "args": [30, 149] + "args": [30, 149.5] }, { "name": "lineTo", - "args": [130, 149] + "args": [130, 149.5] }, { "name": "stroke", "args": [] @@ -1283,7 +1283,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 148.5] + "args": [20, 149] }, { "name": "rotate", "args": [-0] @@ -1304,16 +1304,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 178.7] + "args": [25, 178.5] }, { "name": "lineTo", - "args": [30, 178.7] + "args": [30, 178.5] }, { "name": "moveTo", - "args": [30, 178.7] + "args": [30, 178.5] }, { "name": "lineTo", - "args": [130, 178.7] + "args": [130, 178.5] }, { "name": "stroke", "args": [] @@ -1322,7 +1322,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 178.2] + "args": [20, 178] }, { "name": "rotate", "args": [-0] @@ -1337,16 +1337,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 208.4] + "args": [25, 208.5] }, { "name": "lineTo", - "args": [30, 208.4] + "args": [30, 208.5] }, { "name": "moveTo", - "args": [30, 208.4] + "args": [30, 208.5] }, { "name": "lineTo", - "args": [130, 208.4] + "args": [130, 208.5] }, { "name": "stroke", "args": [] @@ -1355,7 +1355,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 207.9] + "args": [20, 208] }, { "name": "rotate", "args": [-0] @@ -1370,16 +1370,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 238.1] + "args": [25, 238.5] }, { "name": "lineTo", - "args": [30, 238.1] + "args": [30, 238.5] }, { "name": "moveTo", - "args": [30, 238.1] + "args": [30, 238.5] }, { "name": "lineTo", - "args": [130, 238.1] + "args": [130, 238.5] }, { "name": "stroke", "args": [] @@ -1388,7 +1388,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 237.6] + "args": [20, 238] }, { "name": "rotate", "args": [-0] @@ -1403,16 +1403,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 267.8] + "args": [25, 267.5] }, { "name": "lineTo", - "args": [30, 267.8] + "args": [30, 267.5] }, { "name": "moveTo", - "args": [30, 267.8] + "args": [30, 267.5] }, { "name": "lineTo", - "args": [130, 267.8] + "args": [130, 267.5] }, { "name": "stroke", "args": [] @@ -1421,7 +1421,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 267.3] + "args": [20, 267] }, { "name": "rotate", "args": [-0] @@ -1650,16 +1650,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 30.2] + "args": [25, 30.5] }, { "name": "lineTo", - "args": [30, 30.2] + "args": [30, 30.5] }, { "name": "moveTo", - "args": [30, 30.2] + "args": [30, 30.5] }, { "name": "lineTo", - "args": [130, 30.2] + "args": [130, 30.5] }, { "name": "stroke", "args": [] @@ -1668,7 +1668,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 29.7] + "args": [20, 30] }, { "name": "rotate", "args": [-0] @@ -1683,16 +1683,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 89.6] + "args": [25, 89.5] }, { "name": "lineTo", - "args": [30, 89.6] + "args": [30, 89.5] }, { "name": "moveTo", - "args": [30, 89.6] + "args": [30, 89.5] }, { "name": "lineTo", - "args": [130, 89.6] + "args": [130, 89.5] }, { "name": "stroke", "args": [] @@ -1701,7 +1701,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 89.1] + "args": [20, 89] }, { "name": "rotate", "args": [-0] @@ -1722,16 +1722,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 149] + "args": [25, 149.5] }, { "name": "lineTo", - "args": [30, 149] + "args": [30, 149.5] }, { "name": "moveTo", - "args": [30, 149] + "args": [30, 149.5] }, { "name": "lineTo", - "args": [130, 149] + "args": [130, 149.5] }, { "name": "stroke", "args": [] @@ -1740,7 +1740,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 148.5] + "args": [20, 149] }, { "name": "rotate", "args": [-0] @@ -1761,16 +1761,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 208.4] + "args": [25, 208.5] }, { "name": "lineTo", - "args": [30, 208.4] + "args": [30, 208.5] }, { "name": "moveTo", - "args": [30, 208.4] + "args": [30, 208.5] }, { "name": "lineTo", - "args": [130, 208.4] + "args": [130, 208.5] }, { "name": "stroke", "args": [] @@ -1779,7 +1779,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 207.9] + "args": [20, 208] }, { "name": "rotate", "args": [-0] @@ -1794,16 +1794,16 @@ describe('Linear Scale', function() { "args": [] }, { "name": "moveTo", - "args": [25, 267.8] + "args": [25, 267.5] }, { "name": "lineTo", - "args": [30, 267.8] + "args": [30, 267.5] }, { "name": "moveTo", - "args": [30, 267.8] + "args": [30, 267.5] }, { "name": "lineTo", - "args": [130, 267.8] + "args": [130, 267.5] }, { "name": "stroke", "args": [] @@ -1812,7 +1812,7 @@ describe('Linear Scale', function() { "args": [] }, { "name": "translate", - "args": [20, 267.3] + "args": [20, 267] }, { "name": "rotate", "args": [-0] diff --git a/test/scale.logarithmic.tests.js b/test/scale.logarithmic.tests.js index 9f46c8805..c462564a9 100644 --- a/test/scale.logarithmic.tests.js +++ b/test/scale.logarithmic.tests.js @@ -81,7 +81,7 @@ describe('Logarithmic Scale tests', function() { scale.update(400, 400); expect(scale.min).toBe(1); - expect(scale.max).toBe(10000); + expect(scale.max).toBe(5000); }); it('Should correctly determine the max & min of string data values', function() { @@ -117,7 +117,7 @@ describe('Logarithmic Scale tests', function() { scale.update(400, 400); expect(scale.min).toBe(1); - expect(scale.max).toBe(10000); + expect(scale.max).toBe(5000); }); it('Should correctly determine the max & min data values when there are hidden datasets', function() { @@ -154,7 +154,7 @@ describe('Logarithmic Scale tests', function() { scale.update(400, 400); expect(scale.min).toBe(1); - expect(scale.max).toBe(10000); + expect(scale.max).toBe(5000); }); it('Should correctly determine the max & min for scatter data', function() { @@ -194,7 +194,7 @@ describe('Logarithmic Scale tests', function() { verticalScale.update(400, 400); expect(verticalScale.min).toBe(1); - expect(verticalScale.max).toBe(1000); + expect(verticalScale.max).toBe(200); var horizontalConfig = Chart.helpers.clone(config); horizontalConfig.position = 'bottom'; @@ -250,7 +250,7 @@ describe('Logarithmic Scale tests', function() { scale.update(400, 400); expect(scale.min).toBe(10); - expect(scale.max).toBe(1000); + expect(scale.max).toBe(200); }); it('Should correctly determine the min and max data values when stacked mode is turned on ignoring hidden datasets', function() { @@ -293,7 +293,7 @@ describe('Logarithmic Scale tests', function() { scale.update(400, 400); expect(scale.min).toBe(10); - expect(scale.max).toBe(1000); + expect(scale.max).toBe(200); }); it('Should ensure that the scale has a max and min that are not equal', function() { @@ -392,9 +392,9 @@ describe('Logarithmic Scale tests', function() { scale.buildTicks(); // Counts down because the lines are drawn top to bottom - expect(scale.ticks).toEqual([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); + expect(scale.ticks).toEqual([80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); expect(scale.start).toBe(1); - expect(scale.end).toBe(100); + expect(scale.end).toBe(80); }); it('Should generate tick marks in the correct order in reversed mode', function() { @@ -427,8 +427,8 @@ describe('Logarithmic Scale tests', function() { scale.buildTicks(); // Counts down because the lines are drawn top to bottom - expect(scale.ticks).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]); - expect(scale.start).toBe(100); + expect(scale.ticks).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80]); + expect(scale.start).toBe(80); expect(scale.end).toBe(1); }); @@ -456,7 +456,7 @@ describe('Logarithmic Scale tests', function() { scale.update(400, 400); - expect(scale.ticks).toEqual(['1e+2', '', '', '', '', '5e+1', '', '', '2e+1', '1e+1', '', '', '', '', '5e+0', '', '', '2e+0', '1e+0']); + expect(scale.ticks).toEqual(['8e+1', '', '', '5e+1', '', '', '2e+1', '1e+1', '', '', '', '', '5e+0', '', '', '2e+0', '1e+0']); }); it('Should build labels using the user supplied callback', function() { @@ -488,7 +488,7 @@ describe('Logarithmic Scale tests', function() { scale.update(400, 400); // Just the index - expect(scale.ticks).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18']); + expect(scale.ticks).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']); }); it('Should get the correct pixel value for a point', function() { @@ -526,9 +526,9 @@ describe('Logarithmic Scale tests', function() { verticalScale.width = 50; verticalScale.height = 110; - expect(verticalScale.getPixelForValue(100, 0, 0)).toBe(5); // top + paddingTop + expect(verticalScale.getPixelForValue(80, 0, 0)).toBe(5); // top + paddingTop expect(verticalScale.getPixelForValue(1, 0, 0)).toBe(105); // bottom - paddingBottom - expect(verticalScale.getPixelForValue(10, 0, 0)).toBe(55); // halfway + expect(verticalScale.getPixelForValue(10, 0, 0)).toBe(52.45387728193468); // halfway var horizontalConfig = Chart.helpers.clone(config); horizontalConfig.position = 'bottom'; @@ -553,8 +553,8 @@ describe('Logarithmic Scale tests', function() { horizontalScale.width = 110; horizontalScale.height = 50; - expect(horizontalScale.getPixelForValue(100, 0, 0)).toBe(105); // right - paddingRight + expect(horizontalScale.getPixelForValue(80, 0, 0)).toBe(105); // right - paddingRight expect(horizontalScale.getPixelForValue(1, 0, 0)).toBe(5); // left + paddingLeft - expect(horizontalScale.getPixelForValue(10, 0, 0)).toBe(55); // halfway + expect(horizontalScale.getPixelForValue(10, 0, 0)).toBe(57.54612271806532); // halfway }); }); \ No newline at end of file