Expose WS subscribe/unsubscribe (#63)
* Expose WS subscribe * Support unsubscribe * Align unsubscribe with method * Basic e2e sub test * Cleanup parameter positions * Small update * Handle non-supplied in output formatter
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Copyright 2017-2018 Jaco Greeff
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
const createApi = require('../../api/src');
|
||||
const createProvider = require('../src/ws');
|
||||
|
||||
describe.skip('e2e', () => {
|
||||
let api;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.setTimeout(30000);
|
||||
api = createApi(createProvider('ws://127.0.0.1:9944'));
|
||||
});
|
||||
|
||||
it('subscribes to client_newHead', (done) => {
|
||||
let count = 0;
|
||||
|
||||
api.chain
|
||||
.newHead((error, data) => {
|
||||
console.log('newHead: result =', [error, data]);
|
||||
|
||||
expect(data).toBeDefined();
|
||||
|
||||
if (++count === 3) {
|
||||
done();
|
||||
}
|
||||
})
|
||||
.then((subscriptionId) => {
|
||||
console.log('newHead: subscriptionId =', subscriptionId);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user