@@ -14,16 +14,23 @@ describe('simple test', () => {
14
14
y : int16
15
15
} )
16
16
17
+ const listSchema = BufferSchema . schema ( 'list' , {
18
+ value : uint8
19
+ } )
20
+
17
21
const snapshotSchema = BufferSchema . schema ( 'snapshot' , {
18
22
time : uint16 ,
19
- data : { players : [ playerSchema ] , castles : [ castleSchema ] }
23
+ single : uint8 ,
24
+ data : { list : [ listSchema ] , players : [ playerSchema ] , castles : [ castleSchema ] }
20
25
} )
21
26
22
27
const SnapshotModel = new Model ( snapshotSchema )
23
28
24
29
const snap = {
25
30
time : 1234 ,
31
+ single : 0 ,
26
32
data : {
33
+ list : [ { value : 1 } , { value : 2 } ] ,
27
34
castles : [ { id : 2 , health : 81 } ] ,
28
35
players : [
29
36
{
@@ -50,12 +57,14 @@ describe('simple test', () => {
50
57
test ( 'should return a buffer' , ( ) => {
51
58
buffer = SnapshotModel . toBuffer ( snap )
52
59
const uint8 = new Uint8Array ( buffer )
60
+
53
61
expect ( typeof buffer ) . toBe ( 'object' )
54
- expect ( uint8 . buffer . byteLength ) . toBe ( 29 )
62
+ expect ( uint8 . buffer . byteLength ) . toBe ( 37 )
55
63
} )
56
64
57
65
test ( 'should fromBuffer' , ( ) => {
58
66
data = SnapshotModel . fromBuffer ( buffer )
67
+
59
68
expect ( data . time ) . toBe ( 1234 )
60
69
expect ( data . data . players [ 0 ] . x ) . toBe ( 145 )
61
70
} )
0 commit comments