Skip to content

Commit 2b2a1a7

Browse files
committed
add test
1 parent cd8465a commit 2b2a1a7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/Select.test.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { ScrollConfig } from 'rc-virtual-list/lib/List';
1313
import React from 'react';
1414
import type { SelectProps } from '../src';
1515
import Select, { OptGroup, Option, useBaseProps } from '../src';
16+
import BaseSelect from '../src/BaseSelect';
1617
import type { BaseSelectRef } from '../src/BaseSelect';
1718
import allowClearTest from './shared/allowClearTest';
1819
import blurTest from './shared/blurTest';
@@ -2464,4 +2465,46 @@ describe('Select.Basic', () => {
24642465
expect(input).toHaveClass(customClassNames.input);
24652466
expect(input).toHaveStyle(customStyle.input);
24662467
});
2468+
it('support classnames and styles for baseSelect', () => {
2469+
const customClassNames = {
2470+
prefix: 'cutsom-prefix',
2471+
suffix: 'custom-suffix',
2472+
list: 'custom-list',
2473+
listItem: 'custom-item',
2474+
input: 'custom-input',
2475+
};
2476+
const customStyle = {
2477+
prefix: { color: 'red' },
2478+
suffix: { color: 'green' },
2479+
list: { color: 'yellow' },
2480+
listItem: { color: 'blue' },
2481+
input: { color: 'black' },
2482+
};
2483+
const { container } = render(
2484+
<BaseSelect
2485+
displayValues={[]}
2486+
prefixCls="rc-select"
2487+
id="base-select"
2488+
open
2489+
classNames={customClassNames}
2490+
styles={customStyle}
2491+
suffixIcon={<div>arrow</div>}
2492+
prefix="Foobar"
2493+
onDisplayValuesChange={() => {}}
2494+
searchValue=""
2495+
onSearch={() => {}}
2496+
OptionList={() => <div>Option List</div>}
2497+
emptyOptions={false}
2498+
/>,
2499+
);
2500+
const prefix = container.querySelector('.rc-select-prefix');
2501+
const suffix = container.querySelector('.rc-select-arrow');
2502+
const input = container.querySelector('.rc-select-selection-search-input');
2503+
expect(prefix).toHaveClass(customClassNames.prefix);
2504+
expect(prefix).toHaveStyle(customStyle.prefix);
2505+
expect(suffix).toHaveClass(customClassNames.suffix);
2506+
expect(suffix).toHaveStyle(customStyle.suffix);
2507+
expect(input).toHaveClass(customClassNames.input);
2508+
expect(input).toHaveStyle(customStyle.input);
2509+
});
24672510
});

0 commit comments

Comments
 (0)