26 lines
981 B
JavaScript
26 lines
981 B
JavaScript
|
import { __extends } from "tslib";
|
||
|
import * as React from 'react';
|
||
|
import { initializeComponentRef } from './initializeComponentRef';
|
||
|
import { mount } from 'enzyme';
|
||
|
describe('initializeComponentRef', function () {
|
||
|
var Foo = /** @class */ (function (_super) {
|
||
|
__extends(Foo, _super);
|
||
|
function Foo(props) {
|
||
|
var _this = _super.call(this, props) || this;
|
||
|
initializeComponentRef(_this);
|
||
|
return _this;
|
||
|
}
|
||
|
Foo.prototype.render = function () {
|
||
|
return React.createElement("div", null);
|
||
|
};
|
||
|
return Foo;
|
||
|
}(React.Component));
|
||
|
it('can resolve componentRef', function () {
|
||
|
var fooRef = React.createRef();
|
||
|
var wrapper = mount(React.createElement(Foo, { componentRef: fooRef }));
|
||
|
expect(fooRef.current).toBe(wrapper.instance());
|
||
|
wrapper.unmount();
|
||
|
expect(fooRef.current).toBeNull();
|
||
|
});
|
||
|
});
|
||
|
//# sourceMappingURL=initializeComponentRef.test.js.map
|