-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove canvas as devDependency (#8015)
- Loading branch information
1 parent
7e5bd6b
commit 19114ef
Showing
5 changed files
with
37 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Mock Canvas/Context2D calls for node tests | ||
// https://github.com/jsdom/jsdom/issues/1782#issuecomment-337656878 | ||
export function mockCanvasApi(JSDOMCanvasElement) { | ||
JSDOMCanvasElement.prototype.getContext = function () { | ||
return { | ||
canvas: this, | ||
clearRect: function () {}, | ||
getImageData: function (x, y, w, h) { | ||
return this.createImageData(w, h); | ||
}, | ||
putImageData: function () {}, | ||
createImageData: function (w, h) { | ||
return {width: w, height: h, data: new Uint8ClampedArray(w * h)}; | ||
}, | ||
drawImage: function () {}, | ||
measureText: function () { | ||
return { | ||
width: 20, | ||
// Additional text metrics needed by tiny-sdf | ||
actualBoundingBoxAscent: 24, | ||
actualBoundingBoxDescent: 0, | ||
actualBoundingBoxLeft: 0, | ||
actualBoundingBoxRight: 20 | ||
}; | ||
}, | ||
fillText: function () {} | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters