From: Evert Timberg Date: Mon, 31 Aug 2015 00:46:26 +0000 (-0400) Subject: More helper tests X-Git-Tag: 2.0.0-alpha4~33^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1428%2Fhead;p=thirdparty%2FChart.js.git More helper tests --- diff --git a/test/core.helpers.tests.js b/test/core.helpers.tests.js index 730222b5b..bbc7f4ab4 100644 --- a/test/core.helpers.tests.js +++ b/test/core.helpers.tests.js @@ -380,6 +380,59 @@ describe('Core helper tests', function() { expect(helpers.previousItem(testData, 0, true)).toEqual(2); expect(helpers.previousItem(testData, 2, false)).toEqual(1); expect(helpers.previousItem(testData, 1, true)).toEqual(0); + }); + + it ('should clear a canvas', function() { + var context = window.createMockContext(); + helpers.clear({ + width: 100, + height: 150, + ctx: context + }); + + expect(context.getCalls()).toEqual([{ + name: 'clearRect', + args: [0, 0, 100, 150] + }]); + }); + it ('should draw a rounded rectangle', function() { + var context = window.createMockContext(); + helpers.drawRoundedRectangle(context, 10, 20, 30, 40, 5); + + expect(context.getCalls()).toEqual([{ + name: 'beginPath', + args: [] + }, { + name: 'moveTo', + args: [15, 20] + }, { + name: 'lineTo', + args: [35, 20] + }, { + name: 'quadraticCurveTo', + args: [40, 20, 40, 25] + }, { + name: 'lineTo', + args: [40, 55] + }, { + name: 'quadraticCurveTo', + args: [40, 60, 35, 60] + }, { + name: 'lineTo', + args: [15, 60] + }, { + name: 'quadraticCurveTo', + args: [10, 60, 10, 55] + }, { + name: 'lineTo', + args: [10, 25] + }, { + name: 'quadraticCurveTo', + args: [10, 20, 15, 20] + }, { + name: 'closePath', + args: [] + }]) }); }); \ No newline at end of file diff --git a/test/mockContext.js b/test/mockContext.js index 239a0a3e4..d8b8e41b8 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -65,10 +65,12 @@ arc: function() {}, beginPath: function() {}, bezierCurveTo: function() {}, + clearRect: function() {}, closePath: function() {}, fill: function() {}, lineTo: function(x, y) {}, moveTo: function(x, y) {}, + quadraticCurveTo: function() {}, restore: function() {}, save: function() {}, setLineDash: function() {},