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
+37
View File
@@ -0,0 +1,37 @@
import { __extends } from "tslib";
import * as React from 'react';
import { createMergedRef } from './createMergedRef';
import { render } from '@testing-library/react';
describe('createMergedRef', function () {
it('can merge refs', function () {
var ref1 = React.createRef();
var Foo = /** @class */ (function (_super) {
__extends(Foo, _super);
function Foo() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.mergedRef = createMergedRef();
return _this;
}
Foo.prototype.render = function () {
return React.createElement("div", { ref: this.mergedRef(this.props.domRef, ref1) });
};
return Foo;
}(React.Component));
var ref2 = React.createRef();
var wrapper = render(React.createElement(Foo, { domRef: ref2 }));
expect(ref1.current).toBeTruthy();
expect(ref2.current).toBeTruthy();
wrapper.unmount();
expect(ref1.current).toBeNull();
expect(ref2.current).toBeNull();
});
it('returns the same ref object with the same input twice', function () {
var mergedRef = createMergedRef();
expect(mergedRef()).toBe(mergedRef());
});
it('should return a new resolver if the refs change', function () {
var mergedRef = createMergedRef();
expect(mergedRef(null)).not.toBe(mergedRef(React.createRef()));
});
});
//# sourceMappingURL=createMergedRef.test.js.map