Use react-redux's batch instead of react's

This commit is contained in:
Fedor Indutny 2021-11-01 16:38:08 -07:00 committed by GitHub
parent 3190f95fac
commit 663cd77eac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 123 additions and 66 deletions

View file

@ -41,6 +41,26 @@ describe('batcher', () => {
assert.ok(processBatch.calledOnceWith([1]), 'Partial batch after timeout');
});
it('should remove scheduled items from a batch', async () => {
const processBatch = sinon.fake.resolves(undefined);
const batcher = createBatcher<number>({
name: 'test',
wait: 5,
maxSize: 100,
processBatch,
});
batcher.add(1);
batcher.add(1);
batcher.add(2);
batcher.removeAll(1);
await sleep(10);
assert.ok(processBatch.calledOnceWith([2]), 'Remove all');
});
it('should flushAndWait a partial batch', async () => {
const processBatch = sinon.fake.resolves(undefined);