Skip to content

Commit

Permalink
refactor(test): add CanvasGradient in bootstrap.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Feb 28, 2024
1 parent a557914 commit 99be96e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/unit/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ class HTMLImageElement extends DOMElement {
}

class CanvasPattern {
// eslint-disable-next-line no-unused-vars
setTransform(matrix) { return undefined; }
setTransform(/* matrix */) { return undefined; }
}
class CanvasGradient {
addColorStop(/* offset, color */) { return undefined; }
}

class DOMMatrix {
// eslint-disable-next-line no-unused-vars
scale(matrix) { return [1, 1, 1, 1]; }
scale(/* matrix */) { return [1, 1, 1, 1]; }
}

// Mock document object for Mocha.
Expand All @@ -116,6 +117,7 @@ global.document = {

canvas.getContext = () => ({
fillRect: () => { },
rect: () => { },
moveTo: () => { },
lineTo: () => { },
beginPath: () => { },
Expand All @@ -142,18 +144,20 @@ global.document = {
};
return imageData;
},
// eslint-disable-next-line no-unused-vars
putImageData: (imageData, dx, dy) => {
putImageData: (imageData) => {
const image = global.document.createElement('img');
image.width = imageData.sw;
image.height = imageData.sh;
return image;
},
// eslint-disable-next-line no-unused-vars
createPattern: (image, repetition) => {
createPattern: (/* image, repetition */) => {
const canvasPattern = new CanvasPattern();
return canvasPattern;
},
createLinearGradient: (/* x0, y0, x1, y1 */) => {
const canvasGradient = new CanvasGradient();
return canvasGradient;
},
canvas,
});

Expand Down

0 comments on commit 99be96e

Please sign in to comment.