Fix broken JavaScript tests (#6498)

* Fixing/removing failing JS tests.

* Fix javascript tests.
This commit is contained in:
Tomasz Drwięga 2017-09-14 19:32:06 +02:00 committed by Gav Wood
parent e3fc3ccada
commit 06ff866e9d
8 changed files with 33 additions and 32 deletions

View File

@ -23,7 +23,8 @@ function newStub () {
const manager = new Manager({
transport: {
isConnected: true
isConnected: true,
on: sinon.stub()
}
});

View File

@ -37,7 +37,8 @@ function stubApi (accounts, info) {
return {
_calls,
transport: {
isConnected: true
isConnected: true,
on: sinon.stub()
},
parity: {
accountsInfo: () => {

View File

@ -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),
@ -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();
});
@ -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);

View File

@ -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')
},

View File

@ -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';
@ -34,7 +35,15 @@ function render (props) {
/>,
{
context: {
store: createRedux()
store: createRedux(),
api: {
transport: {
on: sinon.stub()
},
pubsub: {
subscribeAndGetResult: sinon.stub()
}
}
}
}
).find('Account').shallow();

View File

@ -27,7 +27,11 @@ let instance;
let redux;
function createApi () {
api = {};
api = {
pubsub: {
subscribeAndGetResult: sinon.stub().returns(Promise.reject(new Error('uninitialized')))
}
};
return api;
}

View File

@ -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;
@ -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);

View File

@ -73,7 +73,7 @@ function render () {
return component;
}
describe.only('views/Signer/components/SignRequest', () => {
describe('views/Signer/components/SignRequest', () => {
beforeEach(() => {
render();
});