-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.spec.ts
35 lines (26 loc) · 950 Bytes
/
index.spec.ts
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
30
31
32
33
34
35
import { it, expect } from 'vitest';
import { encode, decode } from './index';
it('should encode / decode simple characters', () => {
const input = 'anything';
const expected = 'YW55dGhpbmc=';
const encoded = encode(input);
expect(encoded).toBe(expected);
const decoded = decode(encoded);
expect(decoded).toBe(input);
});
it('should encode / decode characters outide of Latin1 range', () => {
const input = '我喜欢解码lubię dekodować';
const expected = '5oiR5Zac5qyi6Kej56CBbHViacSZIGRla29kb3dhxIc=';
const encoded = encode(input);
expect(encoded).toBe(expected);
const decoded = decode(encoded);
expect(decoded).toBe(input);
});
it('should encode / decode emojis', () => {
const input = '🩵🩵🩵🩵🩵🩵';
const expected = '8J+ptfCfqbXwn6m18J+ptfCfqbXwn6m1';
const encoded = encode(input);
expect(encoded).toBe(expected);
const decoded = decode(encoded);
expect(decoded).toBe(input);
});