Skip to content

Commit bd84fbe

Browse files
committed
格式调整
1 parent 9747bc4 commit bd84fbe

File tree

1 file changed

+31
-36
lines changed

1 file changed

+31
-36
lines changed

tests/Select.test.tsx

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ describe('Select.Basic', () => {
8181
});
8282

8383
it('renders data-attributes correctly', () => {
84-
85-
8684
const { container } = render(
8785
genSelect({
8886
'data-test': 'test-id',
@@ -1949,44 +1947,41 @@ describe('Select.Basic', () => {
19491947
'Communicated',
19501948
);
19511949
});
1952-
it('filterSort should work with search value when grouping',() => {
1950+
it('filterSort should work with search value when grouping', () => {
19531951
const { container } = render(
19541952
<Select
1955-
open
1956-
showSearch
1957-
searchValue="entry"
1958-
style={{ width: 100 }}
1959-
placeholder="Search to Select"
1960-
optionFilterProp="label"
1961-
filterSort={
1962-
(optionA, optionB, info) => {
1963-
if (!info.searchValue) return 0;
1964-
const labelA = (optionA?.label ?? '').toLowerCase();
1965-
const labelB = (optionB?.label ?? '').toLowerCase();
1966-
const matchA = labelA.startsWith(info.searchValue);
1967-
const matchB = labelB.startsWith(info.searchValue);
1968-
if (matchA && !matchB) return -1;
1969-
if (!matchA && matchB) return 1;
1970-
return labelA.localeCompare(labelB);
1971-
}}
1972-
options={[
1973-
{
1974-
value: 'group1',
1975-
label: 'group1',
1976-
options: [
1977-
{ label: 'Entry1', value: 'Entry1' },
1978-
{ label: 'Entry2', value: 'Entry2' },
1979-
{ label: 'Entry3', value: 'Entry3' },
1980-
{ label: 'Entry', value: 'Entry' },
1981-
],
1982-
},
1983-
]}
1953+
open
1954+
showSearch
1955+
searchValue="entry"
1956+
style={{ width: 100 }}
1957+
placeholder="Search to Select"
1958+
optionFilterProp="label"
1959+
filterSort={(optionA, optionB, info) => {
1960+
if (!info.searchValue) return 0;
1961+
const labelA = (optionA?.label ?? '').toLowerCase();
1962+
const labelB = (optionB?.label ?? '').toLowerCase();
1963+
const matchA = labelA.startsWith(info.searchValue);
1964+
const matchB = labelB.startsWith(info.searchValue);
1965+
if (matchA && !matchB) return -1;
1966+
if (!matchA && matchB) return 1;
1967+
return labelA.localeCompare(labelB);
1968+
}}
1969+
options={[
1970+
{
1971+
value: 'group1',
1972+
label: 'group1',
1973+
options: [
1974+
{ label: 'Entry1', value: 'Entry1' },
1975+
{ label: 'Entry2', value: 'Entry2' },
1976+
{ label: 'Entry3', value: 'Entry3' },
1977+
{ label: 'Entry', value: 'Entry' },
1978+
],
1979+
},
1980+
]}
19841981
/>,
19851982
);
1986-
expect(container.querySelector('.rc-select-item-option-grouped').textContent).toBe(
1987-
'Entry',
1988-
);
1989-
})
1983+
expect(container.querySelector('.rc-select-item-option-grouped').textContent).toBe('Entry');
1984+
});
19901985
it('correctly handles the `tabIndex` prop', () => {
19911986
const { container } = render(<Select tabIndex={0} />);
19921987
expect(container.querySelector('.rc-select').getAttribute('tabindex')).toBeFalsy();

0 commit comments

Comments
 (0)