mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 17:59:57 +08:00
6d685c7e8a
* fix: useSyncState logic * add test case
27 lines
590 B
JavaScript
27 lines
590 B
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import useSyncState from '../hooks/useSyncState';
|
|
|
|
describe('Table', () => {
|
|
it('useSyncState', () => {
|
|
const Test = () => {
|
|
const [getVal, setVal] = useSyncState('light');
|
|
|
|
return (
|
|
<span
|
|
onClick={() => {
|
|
setVal('bamboo');
|
|
}}
|
|
>
|
|
{getVal()}
|
|
</span>
|
|
);
|
|
};
|
|
|
|
const wrapper = mount(<Test />);
|
|
expect(wrapper.text()).toEqual('light');
|
|
wrapper.find('span').simulate('click');
|
|
expect(wrapper.text()).toEqual('bamboo');
|
|
});
|
|
});
|