Skip to content

Commit 295e336

Browse files
committed
Improve Slider test using waitFor instead of setTimeout
1 parent e05c467 commit 295e336

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/components/transition/test/Slider-test.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mount } from '@hypothesis/frontend-testing';
1+
import { mount, waitFor } from '@hypothesis/frontend-testing';
22

33
import { testTransitionComponent } from '../../test/common-tests';
44
import Slider from '../Slider';
@@ -57,16 +57,11 @@ describe('Slider', () => {
5757
assert.equal(containerStyle.height, '200px');
5858
});
5959

60-
it('should transition to collapsed if `direction` changes to `out`', done => {
60+
it('should transition to collapsed if `direction` changes to `out`', async () => {
6161
const wrapper = createSlider({ direction: 'in' });
6262

6363
wrapper.setProps({ direction: 'out' });
64-
65-
setTimeout(() => {
66-
const containerStyle = wrapper.getDOMNode().style;
67-
assert.equal(containerStyle.height, '0px');
68-
done();
69-
}, 1);
64+
await waitFor(() => wrapper.getDOMNode().style.height === '0px');
7065
});
7166

7267
it('should set the container height to "auto" when an expand transition finishes', () => {

0 commit comments

Comments
 (0)