Commit 970386e6 authored by Simon Knox's avatar Simon Knox

review feedback - throw error in smart_callback catch block

parent 17f2ba7f
......@@ -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);
});
}
......
......@@ -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(() => {
jasmine.clock().tick(DEFAULT_SHORT_TIMEOUT);
const oneInterval = smartInterval.cfg.startingInterval * DEFAULT_INCREMENT_FACTOR;
expect(smartInterval.getCurrentInterval()).toEqual(oneInterval);
done();
}, DEFAULT_SHORT_TIMEOUT);
jasmine.clock().uninstall();
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment