mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
21 lines
463 B
JavaScript
21 lines
463 B
JavaScript
|
import { mount } from 'enzyme';
|
||
|
import React from 'react';
|
||
|
import useMountedRef from '../hooks/useMountedRef';
|
||
|
|
||
|
describe('useMountedRef', () => {
|
||
|
it('should work properly', () => {
|
||
|
let ref = null;
|
||
|
|
||
|
const AutoUnmounted = () => {
|
||
|
ref = useMountedRef();
|
||
|
|
||
|
return <div>Mounted</div>;
|
||
|
};
|
||
|
|
||
|
const wrapper = mount(<AutoUnmounted />);
|
||
|
expect(ref.current).toBeTruthy();
|
||
|
wrapper.unmount();
|
||
|
expect(ref.current).toBeFalsy();
|
||
|
});
|
||
|
});
|