Skip to content
Permalink
Browse files

Merge pull request #9663 from gabrielbazan7/fix/tests01

[FIX] tests
  • Loading branch information...
cmgustavo committed Apr 15, 2019
2 parents 4a7ff5c + 4361fc0 commit c5d5ce6735c5f7d6d3f72e65a6ba6229ee05f23f
@@ -43,15 +43,25 @@ describe('HomePage', () => {
instance.plt.resume = new Subject();
instance.plt.pause = new Subject();
});
it('should subscribe to incoming data menu event', () => {
const spy = spyOn(instance, 'subscribeIncomingDataMenuEvent');
it('should subscribe to events', () => {
const subscribeSpy = spyOn(instance.events, 'subscribe');
instance.ionViewDidLoad();
expect(spy).toHaveBeenCalled();
});
it('should subscribe to bws events', () => {
const spy = spyOn(instance, 'subscribeBwsEvents');
instance.ionViewDidLoad();
expect(spy).toHaveBeenCalled();
expect(subscribeSpy).toHaveBeenCalledWith(
'bwsEvent',
instance.bwsEventHandler
);
expect(subscribeSpy).toHaveBeenCalledWith(
'Local/WalletListChange',
instance.setWallets
);
expect(subscribeSpy).toHaveBeenCalledWith(
'Local/TxAction',
instance.walletFocusHandler
);
expect(subscribeSpy).toHaveBeenCalledWith(
'Local/WalletFocus',
instance.walletFocusHandler
);
});
it('should update wallets on platform resume', () => {
instance.ionViewDidLoad();
@@ -47,14 +47,14 @@ describe('PinModalPage', () => {

describe('Methods', () => {
describe('close', () => {
it('should unregister the back button, and pop the page off the navigation stack', () => {
it('should unregister the back button, and dismiss the modal', () => {
const unregisterSpy = spyOn(instance, 'unregister');
instance.close();
instance.platform.resume = new Subject();
instance.platform.pause = new Subject();
instance.ionViewDidLoad();
expect(unregisterSpy).toHaveBeenCalled();
expect(instance.navCtrl.pop).toHaveBeenCalled();
expect(instance.viewCtrl.dismiss).toHaveBeenCalled();
});
it('should clear the countdown timer if it exists', () => {
instance.countDown = setInterval(() => {}, 3000);
@@ -12,7 +12,7 @@ describe('AmountPage', () => {

const wallet = {
coin: 'bch',
status: {
cachedStatus: {
totalBalanceStr: '1.000000',
totalBalanceSat: 100000000,
availableBalanceStr: '1.000000',
@@ -22,6 +22,7 @@ describe('TxDetailsPage', () => {
describe('#saveMemoInfo', () => {
it('should set btx note body to the new txMemo', async () => {
instance.btx = { note: {} };
instance.txMemo = 'new memo';
await instance.saveMemoInfo();
expect(instance.btx.note.body).toEqual('new memo');
});
@@ -34,16 +34,23 @@ describe('WalletDetailsPage', () => {
describe('Lifecycle Hooks', () => {
describe('ionViewDidLoad', () => {
it('should subscribe to events', () => {
const spy = spyOn(instance.events, 'subscribe');
instance.ionViewDidLoad();
expect(spy).toHaveBeenCalledTimes(1);
const subscribeSpy = spyOn(instance.events, 'subscribe');
instance.ionViewWillLoad();
expect(subscribeSpy).toHaveBeenCalledWith(
'Local/WalletUpdate',
instance.updateStatus
);
expect(subscribeSpy).toHaveBeenCalledWith(
'Local/WalletHistoryUpdate',
instance.updateHistory
);
});
});
describe('ionViewDidEnter', () => {
it('should update history', () => {
const spy = spyOn(instance, 'updateAll');
it('should publish to wallet focus event', () => {
const subscribeSpy = spyOn(instance.events, 'publish');
instance.ionViewDidEnter();
expect(spy).toHaveBeenCalled();
expect(subscribeSpy).toHaveBeenCalled();
});
});
});
@@ -16,7 +16,7 @@ describe('Profile Provider', () => {
n: 1,
m: 1
},
status: {
cachedStatus: {
availableBalanceSat: 1000000000 // 10 BTC
},
isComplete: () => {
@@ -34,7 +34,7 @@ describe('Profile Provider', () => {
n: 1,
m: 1
},
status: {
cachedStatus: {
availableBalanceSat: 500000000 // 5 BCH
},
isComplete: () => {
@@ -52,7 +52,7 @@ describe('Profile Provider', () => {
n: 2,
m: 2
},
status: {
cachedStatus: {
availableBalanceSat: 150000000 // 1.50 BTC
},
isComplete: () => {
@@ -34,7 +34,7 @@ describe('Provider: Wallet Provider', () => {
storeLastAddress(_, address) {
return Promise.resolve(address);
}
getTxHistory(_walletId: string) {
fetchTxHistory(_walletId: string) {
return Promise.resolve(txsFromLocal);
}
storeConfig(config) {
@@ -513,7 +513,7 @@ describe('Provider: Wallet Provider', () => {
});
});

describe('Function: getTxHistory', () => {
describe('Function: fetchTxHistory', () => {
it('Should return the completeHistory if exists and isValid', () => {
const wallet: WalletMock = new WalletMock();
wallet.completeHistory = [

0 comments on commit c5d5ce6

Please sign in to comment.
You can’t perform that action at this time.