-
Notifications
You must be signed in to change notification settings - Fork 197
/
Encoder.test.js
44 lines (36 loc) · 1.13 KB
/
Encoder.test.js
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
36
37
38
39
40
41
42
43
44
const {encode, decode} = require('./Encoder.js');
test('empty string', () => {
const str = "";
expect(encode(str)).toEqual([])
expect(decode(encode(str))).toEqual(str)
});
test('space', () => {
const str = " ";
expect(encode(str)).toEqual([220])
expect(decode(encode(str))).toEqual(str)
});
test('tab', () => {
const str = "\t";
expect(encode(str)).toEqual([197])
expect(decode(encode(str))).toEqual(str)
});
test('simple text', () => {
const str = "This is some text";
expect(encode(str)).toEqual([1212, 318, 617, 2420])
expect(decode(encode(str))).toEqual(str)
});
test('multi-token word', () => {
const str = "indivisible";
expect(encode(str)).toEqual([521, 452, 12843])
expect(decode(encode(str))).toEqual(str)
});
test('emojis', () => {
const str = "hello 👋 world 🌍";
expect(encode(str)).toEqual([31373, 50169, 233, 995, 12520, 234, 235])
expect(decode(encode(str))).toEqual(str)
});
test('properties of Object',()=>{
const str = "toString constructor hasOwnProperty valueOf";
expect(encode(str)).toEqual([1462, 10100, 23772, 468, 23858, 21746, 1988, 5189]);
expect(decode(encode(str))).toEqual(str);
})