review feedback - throw error in smart_callback catch block

This commit is contained in:
Simon Knox 2017-11-02 13:13:34 +02:00
parent 17f2ba7fac
commit 970386e603
2 changed files with 12 additions and 8 deletions

View file

@ -5,7 +5,7 @@
export default class SmartInterval {
/**
* @param { function } opts.callback A Promise, called on each iteration (required) unless still in progress
* @param { function } opts.callback Function that returns a promise, called on each iteration unless still in progress (required)
* @param { milliseconds } opts.startingInterval `currentInterval` is set to this initially
* @param { milliseconds } opts.maxInterval `currentInterval` will be incremented to this
* @param { milliseconds } opts.hiddenInterval `currentInterval` is set to this
@ -113,8 +113,9 @@ export default class SmartInterval {
.then(() => {
this.isLoading = false;
})
.catch(() => {
.catch((err) => {
this.isLoading = false;
throw new Error(err);
});
}

View file

@ -58,16 +58,19 @@ describe('SmartInterval', function () {
}, DEFAULT_LONG_TIMEOUT);
});
it('does not increment while waiting for callback', function (done) {
it('does not increment while waiting for callback', function () {
jasmine.clock().install();
const smartInterval = createDefaultSmartInterval({
callback: () => new Promise($.noop),
});
setTimeout(() => {
const oneInterval = smartInterval.cfg.startingInterval * DEFAULT_INCREMENT_FACTOR;
expect(smartInterval.getCurrentInterval()).toEqual(oneInterval);
done();
}, DEFAULT_SHORT_TIMEOUT);
jasmine.clock().tick(DEFAULT_SHORT_TIMEOUT);
const oneInterval = smartInterval.cfg.startingInterval * DEFAULT_INCREMENT_FACTOR;
expect(smartInterval.getCurrentInterval()).toEqual(oneInterval);
jasmine.clock().uninstall();
});
});