diff options
author | 2022-03-07 15:36:22 -0600 | |
---|---|---|
committer | 2022-03-07 15:36:22 -0600 | |
commit | f18ee36dc0abdc5c8ec87734de7962966d16fe65 (patch) | |
tree | c01a7034186cb0bbe5e1d042f4a5dd09bad21ed5 /packages/webapi/test/base64.js | |
parent | 10a9c3412b4f6e8607687a74eafdb150d3222047 (diff) | |
download | astro-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/base64.js')
-rw-r--r-- | packages/webapi/test/base64.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/webapi/test/base64.js b/packages/webapi/test/base64.js new file mode 100644 index 000000000..d8ab66426 --- /dev/null +++ b/packages/webapi/test/base64.js @@ -0,0 +1,48 @@ +import { assert, test } from '../run/test.setup.js' +import { polyfill } from '../mod.js' + +test(() => { + return [ + { + name: 'Supports Base64 Methods', + test() { + const target = {} + + polyfill(target) + + assert.equal('atob' in target, true) + assert.equal('btoa' in target, true) + assert.equal(typeof target['atob'], 'function') + assert.equal(typeof target['btoa'], 'function') + }, + }, + { + name: 'Supports atob(data)', + test() { + const target = {} + + polyfill(target) + + const a = 'SGVsbG8sIHdvcmxk' + const b = target.atob(a) + + assert.equal(a, 'SGVsbG8sIHdvcmxk') + assert.equal(b, 'Hello, world') + }, + }, + { + name: 'Supports btoa(data)', + test() { + const target = {} + + polyfill(target) + + const b = 'Hello, world' + const a = target.btoa(b) + + assert.equal(a, 'SGVsbG8sIHdvcmxk') + assert.equal(b, 'Hello, world') + }, + }, + ] +}) |