2022-04-11 01:29:46 +00:00
|
|
|
import { expect } from 'chai'
|
2022-03-07 21:36:22 +00:00
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
describe('Base64', () => {
|
|
|
|
const target = {}
|
2022-03-07 21:37:50 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
before(() => polyfill(target))
|
2022-03-07 21:37:50 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Supports Base64 Methods', () => {
|
|
|
|
expect(target).to.have.property('atob').that.is.a('function')
|
|
|
|
expect(target).to.have.property('btoa').that.is.a('function')
|
|
|
|
})
|
2022-03-07 21:37:50 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Supports atob(data)', () => {
|
|
|
|
const a = 'SGVsbG8sIHdvcmxk'
|
|
|
|
const b = target.atob(a)
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
expect(a).to.equal('SGVsbG8sIHdvcmxk')
|
|
|
|
expect(b).to.equal('Hello, world')
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Supports btoa(data)', () => {
|
|
|
|
const b = 'Hello, world'
|
|
|
|
const a = target.btoa(b)
|
2022-03-07 21:37:50 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
expect(a).to.equal('SGVsbG8sIHdvcmxk')
|
|
|
|
expect(b).to.equal('Hello, world')
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
})
|