]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
More helper tests 1428/head
authorEvert Timberg <evert.timberg@gmail.com>
Mon, 31 Aug 2015 00:46:26 +0000 (20:46 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Mon, 31 Aug 2015 00:46:26 +0000 (20:46 -0400)
test/core.helpers.tests.js
test/mockContext.js

index 730222b5b57b876f8a71a4d5a97e3abd423951bf..bbc7f4ab447ba881c9c07ffe8069d9afe7d31b2d 100644 (file)
@@ -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
index 239a0a3e48e545c957c211f8bac3a1b15d82b8fa..d8b8e41b8d06ce852c8a867855bc27228edeccf1 100644 (file)
                        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() {},