/
optionals-test.ts
56 lines (49 loc) · 1.44 KB
/
optionals-test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { OptionalsTest, StateEnum } from './test'
describe('useOptionals=deprecatedOnly', () => {
it('has deprecated fields optional members', () => {
const test: OptionalsTest = {
id: 1,
long: 10,
repId: [1, 2],
repState: [StateEnum.ON, StateEnum.OFF],
repLong: [11, 12],
repTruth: [true, false],
repDescription: ["hello", "world"],
repData: [Buffer.alloc(3).fill(0x33), Buffer.alloc(4).fill(0x34), Buffer.alloc(5).fill(0x35)],
optId: 2,
optLong: 13,
optTruth: true,
optDescription: "mumble",
optData: Buffer.alloc(6).fill(0x36),
translations: {
"hello": "hallo",
"world": "wereld",
},
};
const data = OptionalsTest.encode(test).finish();
const test2 = OptionalsTest.decode(data);
expect(test2).toEqual({
id: 1,
state: StateEnum.UNKNOWN,
long: 10,
truth: false,
description: "",
data: new Uint8Array(0),
repId: [1, 2],
repState: [StateEnum.ON, StateEnum.OFF],
repLong: [11, 12],
repTruth: [true, false],
repDescription: ["hello", "world"],
repData: [Buffer.alloc(3).fill(0x33), Buffer.alloc(4).fill(0x34), Buffer.alloc(5).fill(0x35)],
optId: 2,
optLong: 13,
optTruth: true,
optDescription: "mumble",
optData: Buffer.alloc(6).fill(0x36),
translations: {
"hello": "hallo",
"world": "wereld",
},
});
});
})