2022-03-07 16:36:22 -05:00
|
|
|
import { assert, test } from '../run/test.setup.js'
|
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
|
|
|
test(() => {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
name: 'Supports Base64 Methods',
|
|
|
|
test() {
|
|
|
|
const target = {}
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-03-07 16:36:22 -05:00
|
|
|
polyfill(target)
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-03-07 16:36:22 -05:00
|
|
|
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 = {}
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-03-07 16:36:22 -05:00
|
|
|
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 = {}
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-03-07 16:36:22 -05:00
|
|
|
polyfill(target)
|
|
|
|
|
|
|
|
const b = 'Hello, world'
|
|
|
|
const a = target.btoa(b)
|
|
|
|
|
|
|
|
assert.equal(a, 'SGVsbG8sIHdvcmxk')
|
|
|
|
assert.equal(b, 'Hello, world')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
})
|