diff options
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/test/account-data-cache.spec.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gui/test/account-data-cache.spec.ts b/gui/test/account-data-cache.spec.ts index 50118ab20d..7a485b878a 100644 --- a/gui/test/account-data-cache.spec.ts +++ b/gui/test/account-data-cache.spec.ts @@ -258,4 +258,22 @@ describe('IAccountData cache', () => { expect(updateHandler).to.have.been.called.twice; }); }); + it('should not perform a fetch if called twice synchronously', async () => { + const fetchSpy = spy(); + const update = new Promise((resolve, _reject) => { + const fetch = () => { + fetchSpy(); + return Promise.resolve(dummyAccountData); + }; + + const cache = new AccountDataCache(fetch, () => {}); + const onError = (_error: Error) => AccountFetchRetryAction.stop; + cache.fetch(dummyAccountToken, { onFinish: () => {}, onError }); + cache.fetch(dummyAccountToken, { onFinish: () => resolve(), onError }); + }); + + return expect(update).to.eventually.be.fulfilled.then(() => { + expect(fetchSpy).to.have.been.called.once; + }); + }); }); |
