diff --git a/test/element.point.tests.js b/test/element.point.tests.js index e20964422..8a4052ca7 100644 --- a/test/element.point.tests.js +++ b/test/element.point.tests.js @@ -97,6 +97,15 @@ describe('Point element tests', function() { }, { name: 'closePath', args: [], + }, { + name: 'setStrokeStyle', + args: ['rgba(1, 2, 3, 1)'] + }, { + name: 'setLineWidth', + args: [6] + }, { + name: 'setFillStyle', + args: ['rgba(0, 255, 0)'] }, { name: 'fill', args: [], @@ -104,10 +113,6 @@ describe('Point element tests', function() { name: 'stroke', args: [] }]); - - expect(mockContext.lineWidth).toBe(6); - expect(mockContext.strokeStyle).toBe('rgba(1, 2, 3, 1)'); - expect(mockContext.fillStyle).toBe('rgba(0, 255, 0)'); }); it ('should draw correctly with default settings if necessary', function() { @@ -140,6 +145,15 @@ describe('Point element tests', function() { }, { name: 'closePath', args: [], + }, { + name: 'setStrokeStyle', + args: ['rgba(0,0,0,0.1)'] + }, { + name: 'setLineWidth', + args: [1] + }, { + name: 'setFillStyle', + args: ['rgba(0,0,0,0.1)'] }, { name: 'fill', args: [], @@ -147,10 +161,6 @@ describe('Point element tests', function() { name: 'stroke', args: [] }]); - - expect(mockContext.lineWidth).toBe(1); - expect(mockContext.strokeStyle).toBe('rgba(0,0,0,0.1)'); - expect(mockContext.fillStyle).toBe('rgba(0,0,0,0.1)'); }); it ('should not draw if skipped', function() { diff --git a/test/mockContext.js b/test/mockContext.js index ee3ce7ea4..111aabbdf 100644 --- a/test/mockContext.js +++ b/test/mockContext.js @@ -3,6 +3,35 @@ var Context = function() { this._calls = []; // names/args of recorded calls this._initMethods(); + + this._fillStyle = null; + this._lineWidth = null; + this._strokeStyle = null; + + // Define properties here so that we can record each time they are set + Object.defineProperties(this, { + "fillStyle": { + 'get': function() { return this._fillStyle; }, + 'set': function(style) { + this._fillStyle = style; + this.record('setFillStyle', [style]); + } + }, + 'lineWidth': { + 'get': function() { return this._lineWidth; }, + 'set': function (width) { + this._lineWidth = width; + this.record('setLineWidth', [width]); + } + }, + 'strokeStyle': { + 'get': function() { return this._strokeStyle; }, + 'set': function(style) { + this._strokeStyle = style; + this.record('setStrokeStyle', [style]); + } + }, + }); }; Context.prototype._initMethods = function() {