Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created August 4, 2021 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/ddbc226add002c424eae7f8700093f53 to your computer and use it in GitHub Desktop.
Save YonatanKra/ddbc226add002c424eae7f8700093f53 to your computer and use it in GitHub Desktop.
Testing our drawing code
const { draw } = require('./index');
describe('draw', () => {
let canvas, ctx;
beforeEach(function() {
canvas = document.createElement('canvas');
ctx = canvas.getContext('2d');
});
it(`should return the shape's path`, function() {
const shapePath = draw(ctx);
expect(shapePath instanceof Path2D).toBeTruthy();
});
it(`should draw a house on the canvas using the main ctx`, function() {
draw(ctx);
const events = ctx.__getEvents();
expect(events).toMatchSnapshot();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment