Skip to content

Commit 20743c1

Browse files
authored
test: stabilize flaky virtualizer test (#10172)
1 parent 5bd72a3 commit 20743c1

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

packages/component-base/test/virtualizer-scrolling.test.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { expect } from '@vaadin/chai-plugins';
2-
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers';
3-
import sinon from 'sinon';
2+
import { aTimeout, fixtureSync, nextFrame, oneEvent } from '@vaadin/testing-helpers';
43
import { Virtualizer } from '../src/virtualizer.js';
54

65
describe('virtualizer - overscroll', () => {
76
const PREVENT_OVERSCROLL_TIMEOUT = 500;
87
let virtualizer;
98
let scrollTarget;
10-
let clock;
119

1210
beforeEach(() => {
1311
scrollTarget = fixtureSync(`
@@ -29,25 +27,18 @@ describe('virtualizer - overscroll', () => {
2927
});
3028

3129
virtualizer.size = 100;
32-
33-
clock = sinon.useFakeTimers({
34-
shouldClearNativeTimers: true,
35-
});
36-
});
37-
38-
afterEach(() => {
39-
clock.restore();
4030
});
4131

4232
it('should prevent outer scrolling right after reaching the end', async () => {
4333
scrollTarget.scrollTop = scrollTarget.scrollHeight;
44-
await clock.tickAsync();
34+
await oneEvent(scrollTarget, 'scroll');
4535
expect(scrollTarget.style.overscrollBehavior).to.equal('none');
4636
});
4737

4838
it('should allow outer scrolling again after timeout', async () => {
4939
scrollTarget.scrollTop = scrollTarget.scrollHeight;
50-
await clock.tickAsync(PREVENT_OVERSCROLL_TIMEOUT);
40+
await oneEvent(scrollTarget, 'scroll');
41+
await aTimeout(PREVENT_OVERSCROLL_TIMEOUT);
5142
expect(scrollTarget.style.overscrollBehavior).to.be.empty;
5243
});
5344
});

0 commit comments

Comments
 (0)