|
1 | 1 | /* eslint-disable max-classes-per-file */ |
2 | 2 |
|
3 | | -import React, { createRef } from 'react'; |
| 3 | +import React, { StrictMode, createRef } from 'react'; |
4 | 4 | import ReactDOM from 'react-dom'; |
5 | 5 | import { act, cleanup, fireEvent, render } from '@testing-library/react'; |
6 | 6 | import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; |
@@ -820,4 +820,23 @@ describe('Trigger.Basic', () => { |
820 | 820 | expect(isChildUpdate).toBeFalsy(); |
821 | 821 | expect(isGrandsonUpdate).toBeFalsy(); |
822 | 822 | }); |
| 823 | + |
| 824 | + it('should work in StrictMode with autoDestroy', () => { |
| 825 | + const { container } = render( |
| 826 | + <Trigger action={['click']} autoDestroy={true}> |
| 827 | + <div className="target">click</div> |
| 828 | + </Trigger>, |
| 829 | + { wrapper: StrictMode }, |
| 830 | + ); |
| 831 | + |
| 832 | + // click to show |
| 833 | + trigger(container, '.target'); |
| 834 | + expect(document.querySelector('.rc-trigger-popup')).toBeTruthy(); |
| 835 | + // click to hide |
| 836 | + trigger(container, '.target'); |
| 837 | + expect(document.querySelector('.rc-trigger-popup')).toBeFalsy(); |
| 838 | + // click to show |
| 839 | + trigger(container, '.target'); |
| 840 | + expect(document.querySelector('.rc-trigger-popup')).toBeTruthy(); |
| 841 | + }); |
823 | 842 | }); |
0 commit comments