summaryrefslogtreecommitdiff
path: root/packages/webapi/test/imagedata.js
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2022-03-07 15:36:22 -0600
committerGravatar GitHub <noreply@github.com> 2022-03-07 15:36:22 -0600
commitf18ee36dc0abdc5c8ec87734de7962966d16fe65 (patch)
treec01a7034186cb0bbe5e1d042f4a5dd09bad21ed5 /packages/webapi/test/imagedata.js
parent10a9c3412b4f6e8607687a74eafdb150d3222047 (diff)
downloadastro-f18ee36dc0abdc5c8ec87734de7962966d16fe65.tar.gz
astro-f18ee36dc0abdc5c8ec87734de7962966d16fe65.tar.zst
astro-f18ee36dc0abdc5c8ec87734de7962966d16fe65.zip
Add `@astrojs/webapi` package (#2729)@astrojs/webapi@0.11.0
* chore: add @astrojs/webapi * chore: update package.json * fix: update file case * fix: remove lowercase file * chore: update tests to use mocha * chore: update LICENSE
Diffstat (limited to 'packages/webapi/test/imagedata.js')
-rw-r--r--packages/webapi/test/imagedata.js84
1 files changed, 84 insertions, 0 deletions
diff --git a/packages/webapi/test/imagedata.js b/packages/webapi/test/imagedata.js
new file mode 100644
index 000000000..d4a542117
--- /dev/null
+++ b/packages/webapi/test/imagedata.js
@@ -0,0 +1,84 @@
+import { assert, test } from '../run/test.setup.js'
+import { polyfill } from '../mod.js'
+
+test(() => {
+ return [
+ {
+ name: 'Supports ImageData',
+ test() {
+ const target = {}
+
+ polyfill(target)
+
+ assert.equal('ImageData' in target, true)
+ assert.equal(typeof target['ImageData'], 'function')
+ },
+ },
+ {
+ name: 'Supports new (data: Uint8ClampedArray, width: number, height: number): ImageData',
+ test() {
+ const target = {}
+
+ polyfill(target)
+
+ const w = 640
+ const h = 480
+ const d = new Uint8ClampedArray(w * h * 4)
+
+ const id = new target.ImageData(d, w, h)
+
+ assert.equal(id.data, d)
+ assert.equal(id.width, w)
+ assert.equal(id.height, h)
+ },
+ },
+ {
+ name: 'Supports new (data: Uint8ClampedArray, width: number): ImageData',
+ test() {
+ const target = {}
+
+ polyfill(target)
+
+ const w = 640
+ const h = 480
+ const d = new Uint8ClampedArray(w * h * 4)
+
+ const id = new target.ImageData(d, w)
+
+ assert.equal(id.data, d)
+ assert.equal(id.width, w)
+ assert.equal(id.height, h)
+ },
+ },
+ {
+ name: 'Supports new (width: number, height: number): ImageData',
+ test() {
+ const target = {}
+
+ polyfill(target)
+
+ const w = 640
+ const h = 480
+
+ const id = new target.ImageData(w, h)
+
+ assert.equal(id.data.length, w * h * 4)
+ assert.equal(id.width, w)
+ assert.equal(id.height, h)
+ },
+ },
+ {
+ name: 'Supports Object.keys(new ImageData(640, 480))',
+ test() {
+ const target = {}
+
+ polyfill(target)
+
+ const keys = Object.keys(new target.ImageData(640, 480))
+
+ assert.equal(keys.length, 1)
+ assert.equal(keys[0], 'data')
+ },
+ },
+ ]
+})