-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
44 lines (34 loc) · 1.18 KB
/
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
'use strict';
const test = require('ava');
const Serializer = require('./serializer');
const s = new Serializer();
test('encodes simple call', t => {
const msg = [ 'test.call' ];
t.deepEqual(s.decode(s.encode(msg)), msg);
})
test('encodes simple call with string data', t => {
const msg = [ 'test.call', 'string' ];
t.deepEqual(s.decode(s.encode(msg)), msg);
})
test('encodes simple call with empty string data', t => {
const msg = [ 'test.call', '' ];
t.deepEqual(s.decode(s.encode(msg)), msg);
})
test('encodes simple call with boolean data', t => {
const msg1 = [ 'test.call', true ];
t.deepEqual(s.decode(s.encode(msg1)), msg1);
const msg2 = [ 'test.call', false ];
t.deepEqual(s.decode(s.encode(msg2)), msg2);
})
test('encodes simple call with numbers data', t => {
const msg1 = [ 'test.call', 0 ];
t.deepEqual(s.decode(s.encode(msg1)), msg1);
const msg2 = [ 'test.call', 1000 ];
t.deepEqual(s.decode(s.encode(msg2)), msg2);
})
test('encodes simple call with object data', t => {
const msg1 = [ 'test.call', {} ];
t.deepEqual(s.decode(s.encode(msg1)), msg1);
const msg2 = [ 'test.call', { test: 'test' } ];
t.deepEqual(s.decode(s.encode(msg2)), msg2);
})