Skip to content

Commit 6d5bbb1

Browse files
committed
Update simple.test.js
1 parent 3170df6 commit 6d5bbb1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/simple.test.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ describe('simple test', () => {
1414
y: int16
1515
})
1616

17+
const listSchema = BufferSchema.schema('list', {
18+
value: uint8
19+
})
20+
1721
const snapshotSchema = BufferSchema.schema('snapshot', {
1822
time: uint16,
19-
data: { players: [playerSchema], castles: [castleSchema] }
23+
single: uint8,
24+
data: { list: [listSchema], players: [playerSchema], castles: [castleSchema] }
2025
})
2126

2227
const SnapshotModel = new Model(snapshotSchema)
2328

2429
const snap = {
2530
time: 1234,
31+
single: 0,
2632
data: {
33+
list: [{ value: 1 }, { value: 2 }],
2734
castles: [{ id: 2, health: 81 }],
2835
players: [
2936
{
@@ -50,12 +57,14 @@ describe('simple test', () => {
5057
test('should return a buffer', () => {
5158
buffer = SnapshotModel.toBuffer(snap)
5259
const uint8 = new Uint8Array(buffer)
60+
5361
expect(typeof buffer).toBe('object')
54-
expect(uint8.buffer.byteLength).toBe(29)
62+
expect(uint8.buffer.byteLength).toBe(37)
5563
})
5664

5765
test('should fromBuffer', () => {
5866
data = SnapshotModel.fromBuffer(buffer)
67+
5968
expect(data.time).toBe(1234)
6069
expect(data.data.players[0].x).toBe(145)
6170
})

0 commit comments

Comments
 (0)