Skip to content

Commit bbb9763

Browse files
committed
chore: add test for text encoder/decoder
1 parent 31e94a6 commit bbb9763

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/text-codec.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict'
2+
3+
/* eslint-env mocha */
4+
const { expect } = require('aegir/utils/chai')
5+
const TextEncoder = require('../src/text-encoder')
6+
const TextDecoder = require('../src/text-decoder')
7+
8+
describe('text encode/decode', () => {
9+
const data = Uint8Array.from([
10+
104,
11+
101,
12+
108,
13+
108,
14+
111,
15+
32,
16+
119,
17+
111,
18+
114,
19+
108,
20+
100
21+
])
22+
23+
it('can encode text', () => {
24+
const bytes = new TextEncoder().encode('hello world')
25+
expect(bytes).to.be.deep.equal(data)
26+
})
27+
28+
it('can decode text', () => {
29+
const text = new TextDecoder().decode(data)
30+
expect(text).to.be.equal('hello world')
31+
})
32+
})

0 commit comments

Comments
 (0)