Skip to content

Commit e1f5d02

Browse files
committed
fix(test): fix rAF killing userselecthack tests
1 parent 18e525f commit e1f5d02

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

specs/draggable.spec.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('react-draggable', function () {
2626

2727
beforeEach(function() {
2828
spyOn(console, 'error');
29+
spyOn(window, 'requestAnimationFrame').and.callFake(function(fn) { fn(); });
2930
});
3031

3132
afterEach(function() {
@@ -368,6 +369,8 @@ describe('react-draggable', function () {
368369
assert(document.body.classList.contains('react-draggable-transparent-selection'));
369370
TestUtils.Simulate.mouseUp(node);
370371
assert(!document.body.classList.contains('react-draggable-transparent-selection'));
372+
373+
assert(window.requestAnimationFrame.calls.any()); // should have been called
371374
});
372375

373376
it('should not add and remove transparent selection class when disabled', function () {
@@ -385,6 +388,8 @@ describe('react-draggable', function () {
385388
assert(!document.body.classList.contains('react-draggable-transparent-selection'));
386389
TestUtils.Simulate.mouseUp(node);
387390
assert(!document.body.classList.contains('react-draggable-transparent-selection'));
391+
392+
assert(!window.requestAnimationFrame.calls.any()); // should not have been called
388393
});
389394

390395
it('should not add and remove transparent selection class when onStart returns false', function () {
@@ -403,6 +408,8 @@ describe('react-draggable', function () {
403408
assert(!document.body.classList.contains('react-draggable-transparent-selection'));
404409
TestUtils.Simulate.mouseUp(node);
405410
assert(!document.body.classList.contains('react-draggable-transparent-selection'));
411+
412+
assert(!window.requestAnimationFrame.calls.any()); // should not have been called
406413
});
407414

408415
it('should not defocus inputs when unmounting', function () {

0 commit comments

Comments
 (0)