Skip to content

Commit

Permalink
CHANGELOG.md updated and AbstractSocketProviderTest extended
Browse files Browse the repository at this point in the history
  • Loading branch information
nivida committed Aug 5, 2019
1 parent cca6567 commit 395dba9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- stripHexPrefix fixed (#2989)
- BatchRequest error handling fixed for callbacks (#2993)
- ``reconnected`` event and reconnection timeout option added to WebsocketProvider (#2994)
- ``clearSubscriptions`` fixed (#3007)
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ describe('AbstractSocketProviderTest', () => {

it('calls clearSubscriptions and one unsubscribe call returns false', async () => {
abstractSocketProvider.subscriptions.set('0x0', {id: '0x0', subscribeMethod: 'eth_subscribe'});
abstractSocketProvider.removeAllListeners = jest.fn();

abstractSocketProvider.send = jest.fn((subscribeMethod, parameters) => {
expect(subscribeMethod).toEqual('eth_unsubscribe');
Expand All @@ -274,7 +273,6 @@ describe('AbstractSocketProviderTest', () => {

it('calls clearSubscriptions and all unsubscribe calls are returning true', async () => {
abstractSocketProvider.subscriptions.set('0x0', {id: '0x0', subscribeMethod: 'eth_subscribe'});
abstractSocketProvider.removeAllListeners = jest.fn();

abstractSocketProvider.send = jest.fn((subscribeMethod, parameters) => {
expect(subscribeMethod).toEqual('eth_unsubscribe');
Expand All @@ -291,6 +289,30 @@ describe('AbstractSocketProviderTest', () => {
expect(abstractSocketProvider.subscriptions).toEqual(new Map());
});

it('calls clearSubscriptions without a type given and all unsubscribe calls are returning true', async () => {
abstractSocketProvider.subscriptions.set('0x0', {id: '0x0', subscribeMethod: 'eth_subscribe'});

abstractSocketProvider.send = jest.fn((subscribeMethod, parameters) => {
expect(subscribeMethod).toEqual('eth_unsubscribe');

expect(parameters).toEqual(['0x0']);

return Promise.resolve(true);
});

const response = await abstractSocketProvider.clearSubscriptions();

expect(response).toEqual(true);

expect(abstractSocketProvider.subscriptions).toEqual(new Map());
});

it('calls clearSubscriptions without running subscriptions and resolves with true', async () => {
const response = await abstractSocketProvider.clearSubscriptions();

expect(response).toEqual(true);
});

it('calls getSubscriptionEvent and has to iterate over all items', () => {
abstractSocketProvider.subscriptions.set('ID', {id: '0x0'});

Expand Down

0 comments on commit 395dba9

Please sign in to comment.