1 | // Copyright 2017-2018 @polkadot/api-provider authors & contributors
|
2 | // This software may be modified and distributed under the terms
|
3 | // of the ISC license. See the LICENSE file for details.
|
4 |
|
5 | import createCoder from './index';
|
6 |
|
7 | describe('encodeObject', () => {
|
8 | let coder;
|
9 |
|
10 | beforeEach(() => {
|
11 | coder = createCoder();
|
12 | });
|
13 |
|
14 | it('starts with id === 0 (nothing sent)', () => {
|
15 | expect(coder.getId()).toEqual(0);
|
16 | });
|
17 |
|
18 | it('encodes a valid JsonRPC object', () => {
|
19 | expect(
|
20 | coder.encodeObject('method', 'params')
|
21 | ).toEqual({
|
22 | id: 1,
|
23 | jsonrpc: '2.0',
|
24 | method: 'method',
|
25 | params: 'params'
|
26 | });
|
27 | expect(coder.getId()).toEqual(1);
|
28 | });
|
29 | });
|