1
0
Fork 0
Browse Source

refactor: swap jsdom + canvas dep in favour of a mock object

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
combat-scorched-earth-from-outer-space
André Jaenisch 10 months ago
parent
commit
da945ee840
Signed by: ryuno-ki
GPG Key ID: 5A668E771F1ED854
  1. 1514
      package-lock.json
  2. 2
      package.json
  3. 19
      test/js/draw.test.js

1514
package-lock.json generated

File diff suppressed because it is too large Load Diff

2
package.json

@ -50,7 +50,6 @@
"@rollup/plugin-buble": "0.21.3",
"@rollup/plugin-commonjs": "20.0.0",
"@rollup/plugin-node-resolve": "13.0.4",
"canvas": "2.8.0",
"chai": "4.3.4",
"clean-css-cli": "5.3.3",
"eslint": "7.32.0",
@ -65,7 +64,6 @@
"jsdoc": "3.6.7",
"jsdoc-mermaid": "1.0.0",
"jsdoc-tsimport-plugin": "1.0.5",
"jsdom": "17.0.0",
"markdownlint-cli": "0.28.1",
"mocha": "9.0.3",
"npm": "7.20.6",

19
test/js/draw.test.js

@ -1,20 +1,13 @@
import { expect } from 'chai'
import jsdom from 'jsdom'
import { drawShape } from '../../src/js/draw.js'
import { RigidShape } from '../../src/js/shape.js'
import { Vec2 } from '../../src/js/vector.js'
// Requires npm canvas package here to be installed
const { JSDOM } = jsdom
const { window } = new JSDOM('')
const { document } = window
describe('drawShape', function () {
it('should draw a shape onto a canvas', function () {
// Arrange
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
const context = makeContext()
const center = Vec2(500, 200)
const friction = 20
const restitution = 0
@ -40,3 +33,13 @@ describe('drawShape', function () {
// TODO: Assert pixel on canvas
})
})
function makeContext () {
return {
restore: function () {},
rotate: function () {},
save: function () {},
strokeRect: function () {},
translate: function () {},
}
}

Loading…
Cancel
Save