test: migrate part of Tree-Select tests (#37190)

This commit is contained in:
lijianan 2022-08-23 11:57:50 +08:00 committed by GitHub
parent db0344c85f
commit 7f49d221a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -231,7 +231,6 @@ exports[`TreeSelect TreeSelect Custom Icons should support customized icons 1`]
aria-hidden="true" aria-hidden="true"
class="ant-select-selection-search-mirror" class="ant-select-selection-search-mirror"
> >
 
</span> </span>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
import { mount } from 'enzyme';
import React from 'react'; import React from 'react';
import { render } from '../../../tests/utils';
import TreeSelect, { TreeNode } from '..'; import TreeSelect, { TreeNode } from '..';
import focusTest from '../../../tests/shared/focusTest'; import focusTest from '../../../tests/shared/focusTest';
import mountTest from '../../../tests/shared/mountTest'; import mountTest from '../../../tests/shared/mountTest';
@ -12,7 +12,7 @@ describe('TreeSelect', () => {
describe('TreeSelect Custom Icons', () => { describe('TreeSelect Custom Icons', () => {
it('should support customized icons', () => { it('should support customized icons', () => {
const wrapper = mount( const { container } = render(
<TreeSelect <TreeSelect
showSearch showSearch
clearIcon={<span>clear</span>} clearIcon={<span>clear</span>}
@ -32,22 +32,23 @@ describe('TreeSelect', () => {
</TreeSelect>, </TreeSelect>,
); );
expect(wrapper.render()).toMatchSnapshot(); expect(container.firstChild).toMatchSnapshot();
}); });
it('should `treeIcon` work', () => { it('should `treeIcon` work', () => {
const wrapper = mount( const { container } = render(
<TreeSelect treeIcon open> <TreeSelect treeIcon open>
<TreeNode value="parent 1" title="parent 1" icon={<span>Bamboo</span>} /> <TreeNode value="parent 1" title="parent 1" icon={<span>Bamboo</span>} />
</TreeSelect>, </TreeSelect>,
); );
expect(wrapper.render()).toMatchSnapshot(); expect(container.firstChild).toMatchSnapshot();
}); });
}); });
it('should support notFoundContent', () => { it('should support notFoundContent', () => {
const wrapper = mount(<TreeSelect treeIcon open notFoundContent="notFoundContent" />); const content = 'notFoundContent';
expect(wrapper.text()).toBe('notFoundContent'); const { container } = render(<TreeSelect treeIcon open notFoundContent={content} />);
expect(container.querySelector('.ant-select-empty')?.innerHTML).toBe(content);
}); });
}); });