ant-design/components/_util/__tests__/useMountedRef.test.js

21 lines
463 B
JavaScript
Raw Normal View History

2021-12-28 17:21:00 +08:00
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();
});
});