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({ const manager = new Manager({
transport: { transport: {
isConnected: true isConnected: true,
on: sinon.stub()
} }
}); });

View File

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

View File

@ -31,6 +31,12 @@ let store;
function createApi () { function createApi () {
api = { api = {
transport: {
on: sinon.stub()
},
pubsub: {
subscribeAndGetResult: sinon.stub().returns(Promise.reject(new Error('not connected')))
},
parity: { parity: {
hardwareAccountsInfo: sinon.stub().resolves({ ADDRESS: WALLET }), hardwareAccountsInfo: sinon.stub().resolves({ ADDRESS: WALLET }),
setAccountMeta: sinon.stub().resolves(true), 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', () => { describe('scan', () => {
beforeEach(() => { beforeEach(() => {
sinon.spy(store, 'setScanning'); sinon.spy(store, 'setScanning');
sinon.spy(store, 'setWallets'); sinon.spy(store, 'setWallets');
sinon.spy(store, 'scanLedger'); sinon.spy(store, 'scanLedger');
sinon.spy(store, 'scanParity');
return store.scan(); return store.scan();
}); });
@ -219,17 +214,12 @@ describe('mobx/HardwareStore', () => {
store.setScanning.restore(); store.setScanning.restore();
store.setWallets.restore(); store.setWallets.restore();
store.scanLedger.restore(); store.scanLedger.restore();
store.scanParity.restore();
}); });
it('calls scanLedger', () => { it('calls scanLedger', () => {
expect(store.scanLedger).to.have.been.called; expect(store.scanLedger).to.have.been.called;
}); });
it('calls scanParity', () => {
expect(store.scanParity).to.have.been.called;
});
it('sets and resets the scanning state', () => { it('sets and resets the scanning state', () => {
expect(store.setScanning).to.have.been.calledWith(true); expect(store.setScanning).to.have.been.calledWith(true);
expect(store.setScanning).to.have.been.calledWith(false); expect(store.setScanning).to.have.been.calledWith(false);

View File

@ -48,6 +48,12 @@ let store;
function createApi () { function createApi () {
api = { api = {
transport: {
on: sinon.stub()
},
pubsub: {
subscribeAndGetResult: sinon.stub().returns(Promise.reject(new Error('not connected')))
},
net: { net: {
version: sinon.stub().resolves('2') version: sinon.stub().resolves('2')
}, },

View File

@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import sinon from 'sinon';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import React from 'react'; import React from 'react';
@ -34,7 +35,15 @@ function render (props) {
/>, />,
{ {
context: { context: {
store: createRedux() store: createRedux(),
api: {
transport: {
on: sinon.stub()
},
pubsub: {
subscribeAndGetResult: sinon.stub()
}
}
} }
} }
).find('Account').shallow(); ).find('Account').shallow();

View File

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

View File

@ -18,7 +18,7 @@ import sinon from 'sinon';
import AccountStore from './accountStore'; 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 api;
let store; 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', () => { describe('makeDefaultAccount', () => {
beforeEach(() => { beforeEach(() => {
return store.makeDefaultAccount(ACCOUNT_NEW); return store.makeDefaultAccount(ACCOUNT_NEW);

View File

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