forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: optimization type in test case (ant-design#43449)
* test: optimization type in test case * fix lint --------- Co-authored-by: 我们去月球漫步 <[email protected]>
- Loading branch information
1 parent
9b03ce4
commit a998569
Showing
3 changed files
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
import type { TriggerProps } from '@rc-component/trigger'; | ||
import type { TriggerProps, TriggerRef } from '@rc-component/trigger'; | ||
import MockTrigger from '@rc-component/trigger/lib/mock'; | ||
import * as React from 'react'; | ||
import { TriggerMockContext } from '../../shared/demoTestContext'; | ||
|
||
let OriginTrigger = jest.requireActual('@rc-component/trigger'); | ||
OriginTrigger = OriginTrigger.default ?? OriginTrigger; | ||
|
||
const ForwardTrigger = React.forwardRef<any, TriggerProps>((props, ref) => { | ||
const ForwardTrigger = React.forwardRef<TriggerRef, TriggerProps>((props, ref) => { | ||
const context = React.useContext(TriggerMockContext); | ||
|
||
const mergedPopupVisible = context?.popupVisible ?? props.popupVisible; | ||
(global as any).triggerProps = props; | ||
|
||
const mergedProps = { | ||
const mergedProps: TriggerProps = { | ||
...props, | ||
ref, | ||
popupVisible: mergedPopupVisible as boolean, | ||
popupVisible: mergedPopupVisible, | ||
}; | ||
|
||
if (context?.mock === false) { | ||
return <OriginTrigger {...mergedProps} />; | ||
return <OriginTrigger ref={ref} {...mergedProps} />; | ||
} | ||
return <MockTrigger {...mergedProps} />; | ||
return <MockTrigger ref={ref} {...mergedProps} />; | ||
}); | ||
|
||
export default ForwardTrigger; |