first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import { __extends } from "tslib";
import * as React from 'react';
import { safeRequestAnimationFrame } from './safeRequestAnimationFrame';
import { render } from '@testing-library/react';
describe('safeRequestAnimationFrame', function () {
var rafCalled = false;
var Foo = /** @class */ (function (_super) {
__extends(Foo, _super);
function Foo(props) {
var _this = _super.call(this, props) || this;
_this._raf = safeRequestAnimationFrame(_this);
return _this;
}
Foo.prototype.render = function () {
return React.createElement("div", null, "Hello");
};
Foo.prototype.componentDidMount = function () {
this._raf(function () { return (rafCalled = true); });
};
return Foo;
}(React.Component));
beforeEach(function () {
rafCalled = false;
jest.useFakeTimers();
});
afterEach(function () {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
it('can request animation frame', function () {
var component = render(React.createElement(Foo, null));
expect(rafCalled).toEqual(false);
jest.runOnlyPendingTimers();
expect(rafCalled).toEqual(true);
component.unmount();
});
it('can cancel request animation frame', function () {
var component = render(React.createElement(Foo, null));
expect(rafCalled).toEqual(false);
component.unmount();
jest.runOnlyPendingTimers();
expect(rafCalled).toEqual(false);
});
});
//# sourceMappingURL=safeRequestAnimationFrame.test.js.map