summaryrefslogtreecommitdiffhomepage
path: root/gui/test
diff options
context:
space:
mode:
Diffstat (limited to 'gui/test')
-rw-r--r--gui/test/account-data-cache.spec.ts67
1 files changed, 11 insertions, 56 deletions
diff --git a/gui/test/account-data-cache.spec.ts b/gui/test/account-data-cache.spec.ts
index 6839e7a1eb..bec1c6ef91 100644
--- a/gui/test/account-data-cache.spec.ts
+++ b/gui/test/account-data-cache.spec.ts
@@ -1,4 +1,4 @@
-import AccountDataCache, { AccountFetchRetryAction } from '../src/main/account-data-cache';
+import AccountDataCache from '../src/main/account-data-cache';
import { IAccountData } from '../src/shared/daemon-rpc-types';
import sinon from 'sinon';
import { expect, spy } from 'chai';
@@ -28,10 +28,7 @@ describe('IAccountData cache', () => {
const watcher = new Promise((resolve, reject) => {
cache.fetch(dummyAccountToken, {
onFinish: () => resolve(),
- onError: (_error: Error) => {
- reject();
- return AccountFetchRetryAction.stop;
- },
+ onError: (_error: Error) => reject(),
});
});
@@ -47,10 +44,7 @@ describe('IAccountData cache', () => {
const watcher = new Promise((resolve, reject) => {
cache.fetch(dummyAccountToken, {
onFinish: (_reason?: any) => resolve(),
- onError: (_error: Error) => {
- reject();
- return AccountFetchRetryAction.stop;
- },
+ onError: (_error: Error) => reject(),
});
});
@@ -66,10 +60,7 @@ describe('IAccountData cache', () => {
cache.fetch(dummyAccountToken, {
onFinish: () => {},
- onError: (_error: Error) => {
- reject();
- return AccountFetchRetryAction.stop;
- },
+ onError: (_error: Error) => reject(),
});
});
@@ -94,34 +85,7 @@ describe('IAccountData cache', () => {
cache.fetch(dummyAccountToken, {
onFinish: () => reject(),
- onError: (_error: Error) => AccountFetchRetryAction.retry,
- });
- });
-
- return expect(update).to.eventually.be.fulfilled;
- });
-
- it('should not retry if told to stop', async () => {
- const update = new Promise((resolve, reject) => {
- let firstAttempt = true;
- const fetch = () => {
- if (firstAttempt) {
- firstAttempt = false;
- setTimeout(() => clock.tick(14000), 0);
- return Promise.reject(new Error('First attempt fails'));
- } else {
- reject();
- return Promise.resolve(dummyAccountData);
- }
- };
-
- const cache = new AccountDataCache(fetch, () => resolve());
-
- setTimeout(resolve, 12000);
-
- cache.fetch(dummyAccountToken, {
- onFinish: () => {},
- onError: (_error: Error) => AccountFetchRetryAction.stop,
+ onError: (_error: Error) => {},
});
});
@@ -129,7 +93,7 @@ describe('IAccountData cache', () => {
});
it('should cancel first fetch', async () => {
- const firstError = spy((_error: Error) => AccountFetchRetryAction.stop);
+ const firstError = spy((_error: Error) => {});
const secondSuccess = spy();
const update = new Promise<IAccountData>((resolve, reject) => {
@@ -140,10 +104,7 @@ describe('IAccountData cache', () => {
cache.fetch('1231231231', {
onFinish: secondSuccess,
- onError: () => {
- reject();
- return AccountFetchRetryAction.stop;
- },
+ onError: () => reject(),
});
return new Promise<IAccountData>((resolve) => {
@@ -199,10 +160,7 @@ describe('IAccountData cache', () => {
cache.fetch(dummyAccountToken, {
onFinish: () => {},
- onError: (_error: Error) => {
- reject();
- return AccountFetchRetryAction.stop;
- },
+ onError: (_error: Error) => reject(),
});
});
@@ -236,10 +194,7 @@ describe('IAccountData cache', () => {
cache.fetch(dummyAccountToken, {
onFinish: () => {},
- onError: (_error: Error) => {
- firstError();
- return AccountFetchRetryAction.retry;
- },
+ onError: (_error: Error) => firstError(),
});
setTimeout(() => {
cache.fetch(dummyAccountToken, {
@@ -247,7 +202,7 @@ describe('IAccountData cache', () => {
secondSuccess();
setTimeout(resolve);
},
- onError: (_error: Error) => AccountFetchRetryAction.stop,
+ onError: (_error: Error) => {},
});
});
});
@@ -268,7 +223,7 @@ describe('IAccountData cache', () => {
};
const cache = new AccountDataCache(fetch, () => {});
- const onError = (_error: Error) => AccountFetchRetryAction.stop;
+ const onError = (_error: Error) => {};
cache.fetch(dummyAccountToken, { onFinish: () => {}, onError });
cache.fetch(dummyAccountToken, { onFinish: () => resolve(), onError });
});