Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix broken JavaScript tests #6498

Merged
merged 3 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion js/src/api/subscriptions/manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function newStub () {

const manager = new Manager({
transport: {
isConnected: true
isConnected: true,
on: sinon.stub()
}
});

Expand Down
3 changes: 2 additions & 1 deletion js/src/api/subscriptions/personal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ function stubApi (accounts, info) {
return {
_calls,
transport: {
isConnected: true
isConnected: true,
on: sinon.stub()
},
parity: {
accountsInfo: () => {
Expand Down
22 changes: 6 additions & 16 deletions js/src/mobx/hardwareStore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ let store;

function createApi () {
api = {
transport: {
on: sinon.stub()
},
pubsub: {
subscribeAndGetResult: sinon.stub().returns(Promise.reject(new Error('not connected')))
},
parity: {
hardwareAccountsInfo: sinon.stub().resolves({ ADDRESS: WALLET }),
setAccountMeta: sinon.stub().resolves(true),
Expand Down Expand Up @@ -195,22 +201,11 @@ describe('mobx/HardwareStore', () => {
});
});

describe('scanParity', () => {
beforeEach(() => {
return store.scanParity();
});

it('calls parity_hardwareAccountsInfo', () => {
expect(api.parity.hardwareAccountsInfo).to.have.been.called;
});
});

describe('scan', () => {
beforeEach(() => {
sinon.spy(store, 'setScanning');
sinon.spy(store, 'setWallets');
sinon.spy(store, 'scanLedger');
sinon.spy(store, 'scanParity');

return store.scan();
});
Expand All @@ -219,17 +214,12 @@ describe('mobx/HardwareStore', () => {
store.setScanning.restore();
store.setWallets.restore();
store.scanLedger.restore();
store.scanParity.restore();
});

it('calls scanLedger', () => {
expect(store.scanLedger).to.have.been.called;
});

it('calls scanParity', () => {
expect(store.scanParity).to.have.been.called;
});

it('sets and resets the scanning state', () => {
expect(store.setScanning).to.have.been.calledWith(true);
expect(store.setScanning).to.have.been.calledWith(false);
Expand Down
6 changes: 6 additions & 0 deletions js/src/redux/providers/signerMiddleware.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ let store;

function createApi () {
api = {
transport: {
on: sinon.stub()
},
pubsub: {
subscribeAndGetResult: sinon.stub().returns(Promise.reject(new Error('not connected')))
},
net: {
version: sinon.stub().resolves('2')
},
Expand Down
11 changes: 10 additions & 1 deletion js/src/views/Account/account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import sinon from 'sinon';
import { shallow } from 'enzyme';
import React from 'react';

Expand All @@ -34,7 +35,15 @@ function render (props) {
/>,
{
context: {
store: createRedux()
store: createRedux(),
api: {
transport: {
on: sinon.stub()
},
pubsub: {
subscribeAndGetResult: sinon.stub()
}
}
}
}
).find('Account').shallow();
Expand Down
6 changes: 5 additions & 1 deletion js/src/views/Accounts/accounts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ let instance;
let redux;

function createApi () {
api = {};
api = {
pubsub: {
subscribeAndGetResult: sinon.stub().returns(Promise.reject(new Error('uninitialized')))
}
};

return api;
}
Expand Down
12 changes: 1 addition & 11 deletions js/src/views/ParityBar/accountStore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import sinon from 'sinon';

import AccountStore from './accountStore';

import { ACCOUNT_DEFAULT, ACCOUNT_NEW, createApi } from './parityBar.test.js';
import { ACCOUNT_NEW, createApi } from './parityBar.test.js';

let api;
let store;
Expand Down Expand Up @@ -89,16 +89,6 @@ describe('views/ParityBar/AccountStore', () => {
});
});

describe('loadDefaultAccount', () => {
beforeEach(() => {
return store.loadDefaultAccount();
});

it('load and set the default account', () => {
expect(store.defaultAccount).to.equal(ACCOUNT_DEFAULT);
});
});

describe('makeDefaultAccount', () => {
beforeEach(() => {
return store.makeDefaultAccount(ACCOUNT_NEW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function render () {
return component;
}

describe.only('views/Signer/components/SignRequest', () => {
describe('views/Signer/components/SignRequest', () => {
beforeEach(() => {
render();
});
Expand Down