Skip to content

Commit 4a7ff5c

Browse files
authored
Merge pull request #9662 from gabrielbazan7/fix/tests
[FIX] persistence test and prettier fix
2 parents 2c6c8df + fda5214 commit 4a7ff5c

File tree

14 files changed

+94
-95
lines changed

14 files changed

+94
-95
lines changed

src/pages/home/home.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ export class HomePage {
359359
throw this.translate.instant('No wallets available');
360360
}
361361
this.payProDetailsData = payProDetails;
362-
this.payProDetailsData.host = new URL(payProDetails.payProUrl).host;
362+
this.payProDetailsData.host = new URL(
363+
payProDetails.payProUrl
364+
).host;
363365
this.payProDetailsData.coin = coin;
364366
this.clearCountDownInterval();
365367
this.paymentTimeControl(this.payProDetailsData.expires);
@@ -510,7 +512,7 @@ export class HomePage {
510512
this.events.publish('Local/WalletUpdate', {
511513
walletId: opts.walletId,
512514
incomplete: false,
513-
error: wallet.error,
515+
error: wallet.error
514516
});
515517

516518
if (opts.alsoUpdateHistory) {
@@ -580,11 +582,10 @@ export class HomePage {
580582
});
581583
}
582584

583-
private processWalletError(wallet, err):void {
585+
private processWalletError(wallet, err): void {
584586
wallet.error = wallet.errorObj = null;
585587

586-
if (!err || err == 'INPROGRESS')
587-
return;
588+
if (!err || err == 'INPROGRESS') return;
588589

589590
wallet.cachedStatus = null;
590591
wallet.errorObj = err;

src/pages/integrations/shapeshift/shapeshift-shift/shapeshift-shift.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ export class ShapeshiftShiftPage {
7272
return;
7373
}
7474

75-
7675
this.fromWallets = this.profileProvider.getWallets({
7776
onlyComplete: true,
7877
network: this.network,
79-
hasFunds: true,
80-
})
78+
hasFunds: true
79+
});
8180

8281
if (_.isEmpty(this.fromWallets)) {
8382
this.showErrorAndBack(

src/pages/settings/wallet-settings/wallet-color/wallet-color.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export class WalletColorPage {
5050
opts.colorFor[this.wallet.credentials.walletId] = color;
5151

5252
this.configProvider.set(opts);
53-
this.events.publish('Local/ConfigUpdate', {walletId: this.wallet.credentials.walletId} );
53+
this.events.publish('Local/ConfigUpdate', {
54+
walletId: this.wallet.credentials.walletId
55+
});
5456
this.navCtrl.pop();
5557
}
5658

src/pages/settings/wallet-settings/wallet-name/wallet-name.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ export class WalletNamePage {
7070
this.wallet.credentials.walletId
7171
] = this.walletNameForm.value.walletName;
7272
this.configProvider.set(opts);
73-
this.events.publish('Local/ConfigUpdate', {walletId: this.wallet.credentials.walletId} );
73+
this.events.publish('Local/ConfigUpdate', {
74+
walletId: this.wallet.credentials.walletId
75+
});
7476
this.navCtrl.pop();
7577
}
7678
}

src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-information/wallet-information.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export class WalletInformationPage {
8888
};
8989
opts.colorFor[this.wallet.credentials.walletId] = color;
9090
this.configProvider.set(opts);
91-
this.events.publish('Local/ConfigUpdate', {walletId: this.wallet.credentials.walletId} );
91+
this.events.publish('Local/ConfigUpdate', {
92+
walletId: this.wallet.credentials.walletId
93+
});
9294
this.navCtrl.popToRoot();
9395
}
9496

src/pages/settings/wallet-settings/wallet-settings-advanced/wallet-service-url/wallet-service-url.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ export class WalletServiceUrlPage {
107107
this.persistenceProvider.setCleanAndScanAddresses(
108108
this.wallet.credentials.walletId
109109
);
110-
this.events.publish('Local/ConfigUpdate', {walletId: this.wallet.credentials.walletId} );
110+
this.events.publish('Local/ConfigUpdate', {
111+
walletId: this.wallet.credentials.walletId
112+
});
111113
this.navCtrl.popToRoot().then(() => {
112114
this.reload();
113115
});

src/pages/wallet-details/wallet-details.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ export class WalletDetailsPage extends WalletTabsChild {
172172
}
173173

174174
private showHistory(loading?: boolean) {
175-
if (!this.wallet.completeHistory)
176-
return;
175+
if (!this.wallet.completeHistory) return;
177176

178177
this.history = this.wallet.completeHistory.slice(
179178
0,
@@ -294,9 +293,9 @@ export class WalletDetailsPage extends WalletTabsChild {
294293
this.showHistory();
295294

296295
// Hide prev history if long downlad is happending...
297-
// if (opts.progress > 5) {
296+
// if (opts.progress > 5) {
298297
// this.history = null;
299-
// }
298+
// }
300299
}
301300
}
302301
};
@@ -328,10 +327,7 @@ export class WalletDetailsPage extends WalletTabsChild {
328327
this.showBalanceButton = false;
329328

330329
let err = this.wallet.errorObj;
331-
if (
332-
err.name &&
333-
err.name.match(/WALLET_NOT_FOUND/)
334-
) {
330+
if (err.name && err.name.match(/WALLET_NOT_FOUND/)) {
335331
this.walletNotRegistered = true;
336332
}
337333
if (err === 'WALLET_NOT_REGISTERED') {

src/providers/bitpay-card/bitpay-card.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ export class BitPayCardProvider {
311311
history = data.data || {};
312312
history['txs'] = this._processTransactions(invoices, history);
313313

314-
this.persistenceProvider.setLastKnownBalance(cardId, history.currentCardBalance);
314+
this.persistenceProvider.setLastKnownBalance(
315+
cardId,
316+
history.currentCardBalance
317+
);
315318

316319
return cb(data.error, history);
317320
},
@@ -453,8 +456,9 @@ export class BitPayCardProvider {
453456
// Async, no problem
454457
_.each(cards, x => {
455458
this.setCurrencySymbol(x);
456-
this.persistenceProvider.getLastKnownBalance(x.eid)
457-
.then( ({balance=null, updatedOn=null}) => {
459+
this.persistenceProvider
460+
.getLastKnownBalance(x.eid)
461+
.then(({ balance = null, updatedOn = null }) => {
458462
x.balance = Number(balance);
459463
x.updateOn = updatedOn;
460464
});

src/providers/http-requests/http-requests.ts

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Observable } from 'rxjs';
66
import { Logger } from '../../providers/logger/logger';
77
import { PlatformProvider } from '../platform/platform';
88

9-
declare var cordova: any;
9+
declare var cordova: any;
1010

1111
@Injectable()
1212
export class HttpRequestsProvider {
@@ -25,17 +25,23 @@ export class HttpRequestsProvider {
2525
if (this.isIOS) {
2626
return new Observable(observer => {
2727
cordova.plugin.http.setDataSerializer('json');
28-
cordova.plugin.http.post(url, data, headers, (res) => {
29-
try {
30-
res.data = JSON.parse(res.data);
31-
} catch(e) {
32-
// TODO
28+
cordova.plugin.http.post(
29+
url,
30+
data,
31+
headers,
32+
res => {
33+
try {
34+
res.data = JSON.parse(res.data);
35+
} catch (e) {
36+
// TODO
37+
}
38+
observer.next(res.data);
39+
observer.complete();
40+
},
41+
err => {
42+
observer.error(err.error);
3343
}
34-
observer.next(res.data);
35-
observer.complete();
36-
}, (err) => {
37-
observer.error(err.error);
38-
});
44+
);
3945
});
4046
} else return this.http.post(url, data, { headers });
4147
}
@@ -44,17 +50,23 @@ export class HttpRequestsProvider {
4450
if (this.isIOS) {
4551
return new Observable(observer => {
4652
cordova.plugin.http.setDataSerializer('json');
47-
cordova.plugin.http.get(url, params, headers, (res) => {
48-
try {
49-
res.data = JSON.parse(res.data);
50-
} catch(e) {
51-
// TODO
53+
cordova.plugin.http.get(
54+
url,
55+
params,
56+
headers,
57+
res => {
58+
try {
59+
res.data = JSON.parse(res.data);
60+
} catch (e) {
61+
// TODO
62+
}
63+
observer.next(res.data);
64+
observer.complete();
65+
},
66+
err => {
67+
observer.error(err.error);
5268
}
53-
observer.next(res.data);
54-
observer.complete();
55-
}, (err) => {
56-
observer.error(err.error);
57-
});
69+
);
5870
});
5971
} else return this.http.get(url, { headers });
6072
}

src/providers/persistence/persistence.spec.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,6 @@ describe('Persistence Provider', () => {
108108
});
109109
});
110110

111-
it('should be able to delete a profile', done => {
112-
const p = { name: 'My profile' };
113-
persistenceProvider
114-
.storeNewProfile(p)
115-
.catch(err => expect(err).toBeNull)
116-
.then(() => {
117-
return persistenceProvider.getProfile();
118-
})
119-
.then(profile => {
120-
expect(typeof profile).toEqual('object');
121-
expect(profile.name).toEqual('My profile');
122-
return persistenceProvider.deleteProfile();
123-
})
124-
.then(() => {
125-
return persistenceProvider.getProfile();
126-
})
127-
.then(profile => {
128-
expect(profile).toBeNull();
129-
})
130-
.then(done);
131-
});
132-
133111
it('should store profile', done => {
134112
const p = { name: 'My profile' };
135113
persistenceProvider

0 commit comments

Comments
 (0)