UNPKG

@cainiaofe/cn-ui-m

Version:
25 lines (24 loc) 971 B
import { renderHook } from '@testing-library/react-hooks'; import { useToolbarButtons } from '../use-toolbar-buttons'; describe('useToolbarButtons', function () { it('should call the disabled function with correct arguments', function () { var selectedKeys = new Set(['key1', 'key2']); var selectedDataSource = [{ id: 'key1' }, { id: 'key2' }]; var disabledMock = jest.fn(); renderHook(function () { return useToolbarButtons({ toolbar: { buttons: [ { children: '批量新增', disabled: disabledMock, }, ], }, selectedKeys: selectedKeys, selectedDataSource: selectedDataSource, }); }); expect(disabledMock).toHaveBeenCalledWith(Array.from(selectedKeys), selectedDataSource); }); });