New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement toBlob and toDataURL #22
Conversation
@robinelvin This pull request will include a proper implementation of If you clone the repo into your node modules folder, you can run these commands to test out this branch.
Please feel free to comment in a new issue if you have trouble. I will do my best to help. |
…r canvaspattern and canvasgradient tests
@jtenner Thank you for the quick response. |
Thanks for all, will release new alpha version quickly. |
v2.0.0-alpha.1 released |
Latest v2.0.0-alpha.1 release works for me. Thanks! |
Goals
src/mock/**/*.js
toBlob and toDataURL problems
When the
"canvas"
package is not installed,toBlob()
andtoDataURL()
will throw errors because thejsdom
package expectscanvas
integration. In this case, we just override the default behavior because we don't expect the canvas package to be available at all.createImageData
This function was left unimplemented by mistake and is included in this pull request via #15 and thanks to @robinelvin.
clip
This function was accidentally left unimplemented, and has the same parameter checks as the
fill()
function, so it was easy to copy paste, and verify parameter inputs.Problems with implementation
If the
"canvas"
package is installed, we call the internal function provided by jsdom. Since we do not install"canvas"
as a development dependency this branch of code that exists on line 14 of./src/mock/prototype.js
becomes uncovered for test coverage.Instead, we use a trap door like this:
This allows the code path to be artificially executed and result in 100% code coverage.
testing
@AdriaRios would you mind testing this fork in your test suite? You can clone the repo into your node-modules folder and run:
Test Coverage
There is currently only one line of code uncovered in
mock/prototype.js
.