From 702b9553e7ed770830a991342215bdd8abb8dcf1 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 30 Aug 2015 20:46:26 -0400 Subject: [PATCH] More helper tests --- test/core.helpers.tests.js | 53 ++++++++++++++++++++++++++++++++++++++ test/mockContext.js | 2 ++ 2 files changed, 55 insertions(+) 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() {},