0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/webapi/test/offscreencanvas.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
923 B
JavaScript
Raw Normal View History

import { expect } from 'chai'
import { polyfill } from '../mod.js'
describe('OffscreenCanvas', () => {
const target = {}
2022-03-07 16:37:50 -05:00
before(() => polyfill(target))
2022-03-07 16:37:50 -05:00
it('Supports OffscreenCanvas', () => {
expect(target).to.have.property('OffscreenCanvas').that.is.a('function')
})
2022-03-07 16:37:50 -05:00
it('Supports new (width: number, height: number): OffscreenCanvas', () => {
const w = 640
const h = 480
const canvas = new target.OffscreenCanvas(w, h)
expect(canvas.width).to.equal(w)
expect(canvas.height).to.equal(h)
})
it('Supports OffscreenCanvas#getContext', () => {
const w = 640
const h = 480
2022-03-07 16:37:50 -05:00
const canvas = new target.OffscreenCanvas(w, h)
const context = canvas.getContext('2d')
expect(context.canvas).to.equal(canvas)
const imageData = context.createImageData(w, h)
expect(imageData.width).to.equal(w)
expect(imageData.height).to.equal(h)
expect(imageData.data).to.have.lengthOf(w * h * 4)
})
})