summaryrefslogtreecommitdiff
path: root/packages/webapi/test/base64.js
blob: 8881784dcb4aa733af9eeb6863bcee41d8495cb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { expect } from 'chai'
import { polyfill } from '../mod.js'

describe('Base64', () => {
	const target = {}

	before(() => polyfill(target))

	it('Supports Base64 Methods', () => {
		expect(target).to.have.property('atob').that.is.a('function')
		expect(target).to.have.property('btoa').that.is.a('function')
	})

	it('Supports atob(data)', () => {
		const a = 'SGVsbG8sIHdvcmxk'
		const b = target.atob(a)

		expect(a).to.equal('SGVsbG8sIHdvcmxk')
		expect(b).to.equal('Hello, world')
	})

	it('Supports btoa(data)', () => {
		const b = 'Hello, world'
		const a = target.btoa(b)

		expect(a).to.equal('SGVsbG8sIHdvcmxk')
		expect(b).to.equal('Hello, world')
	})
})