-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.js
34 lines (30 loc) · 930 Bytes
/
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
import test from 'ava';
import ProtobufMessages from './index';
test(t => {
const
protobufMessages = new ProtobufMessages([
{
file: 'src/main/protobuf/CommonMessages.proto',
protoPayloadType: 'ProtoPayloadType'
},
{
file: 'src/main/protobuf/OpenApiMessages.proto',
protoPayloadType: 'ProtoOAPayloadType'
}
]);
protobufMessages.load();
protobufMessages.build();
const
ProtoPingReq = protobufMessages.getMessageByName('ProtoPingReq'),
protoPingReq = new ProtoPingReq({
timestamp: Date.now()
}),
clientMsgId = 'test',
payloadType = 52;
t.deepEqual(
protoPingReq.timestamp,
protobufMessages.decode(
protobufMessages.encode(payloadType, protoPingReq, clientMsgId)
).payload.timestamp
);
});