ant-design/tests/__mocks__/rc-trigger.tsx
二货爱吃白萝卜 1fc374495f
chore: patch for missing rootClassName (#40217)
* chore: init test

* test: rootClassName inject

* test: part of test

* chore: patch qrcode rootCls

* chore: part rootClassName

* chore: part rootClassName

* test: more test

* test: more test

* test: more test

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* test: more test

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: part rootClassName

* chore: fix lint

* chore: fix lint

* chore: ignore part of lint

* test: update snapshot

* test: fix test case

* chore: fix node test

* chore: adjust render logic

* fix: test

* test: update snapshot

* test: update

* refactor

* chore: fix require module logic
2023-01-20 11:03:50 +08:00

28 lines
817 B
TypeScript

import type { TriggerProps } from 'rc-trigger';
import MockTrigger from 'rc-trigger/lib/mock';
import * as React from 'react';
import { TriggerMockContext } from '../shared/demoTestContext';
let OriginTrigger = jest.requireActual('rc-trigger');
OriginTrigger = OriginTrigger.default ?? OriginTrigger;
const ForwardTrigger = React.forwardRef<any, TriggerProps>((props, ref) => {
const context = React.useContext(TriggerMockContext);
const mergedPopupVisible = context?.popupVisible ?? props.popupVisible;
(global as any).triggerProps = props;
const mergedProps = {
...props,
ref,
popupVisible: mergedPopupVisible as boolean,
};
if (context?.mock === false) {
return <OriginTrigger {...mergedProps} />;
}
return <MockTrigger {...mergedProps} />;
});
export default ForwardTrigger;