diff --git a/src/SortableList/__tests__/index.test.tsx b/src/SortableList/__tests__/index.test.tsx new file mode 100644 index 00000000..d524508f --- /dev/null +++ b/src/SortableList/__tests__/index.test.tsx @@ -0,0 +1,43 @@ +import { act, fireEvent, render } from '@testing-library/react'; +import { Button } from 'antd'; +import { useState } from 'react'; +import { SortableList } from '../index'; + +const Demo = () => { + const [list, setList] = useState(['hello', 'world']); + + return ( + <> + { + console.log('change value', value); + setList(value); + }} + SHOW_STORE_IN_DEVTOOLS + /> + + + ); +}; + +describe('SortableList', () => { + it('toggleSetData', () => { + const { getByText } = render(); + const setDataButton = getByText('Set Data'); + act(() => { + fireEvent.click(setDataButton); + }); + expect(getByText('foo')).toBeInTheDocument(); + expect(getByText('bar')).toBeInTheDocument(); + expect(getByText('yes')).toBeInTheDocument(); + }); +}); diff --git a/src/SortableList/container/StoreUpdater.tsx b/src/SortableList/container/StoreUpdater.tsx index fee7861d..6a633a19 100644 --- a/src/SortableList/container/StoreUpdater.tsx +++ b/src/SortableList/container/StoreUpdater.tsx @@ -48,7 +48,7 @@ const StoreUpdater = forwardRef( useStoreUpdater('initialValues', initialValues, [], (state) => { KeyManagerUpdater(state, 'initialValues'); }); - useStoreUpdater('value', value, [], (state) => { + useStoreUpdater('value', value, [value], (state) => { KeyManagerUpdater(state, 'value'); }); useStoreUpdater('actions', actions);