}, {
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: [],
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() {
}, {
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: [],
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() {
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() {