Skip to content

Commit

Permalink
fix(radio): group can't render outline variant by options prop
Browse files Browse the repository at this point in the history
  • Loading branch information
NWYLZW committed Nov 25, 2023
1 parent e4cda54 commit 3e4564e
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 131 deletions.
2 changes: 1 addition & 1 deletion src/radio/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const RadioGroup = (props: RadioGroupProps) => {
};

const renderOptions = () => {
const Comp = variant.includes('filled') ? Radio.Button : Radio;
const Comp = variant.includes('filled') || variant === 'outline' ? Radio.Button : Radio;
return options.map((item) => {
let label: ReactNode;
let value: string | number;
Expand Down
26 changes: 20 additions & 6 deletions src/radio/__tests__/radio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,27 @@ describe('RadioGroup', () => {

test('variant', () => {
const { container } = render(
<Radio.Group
variant="primary-filled"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>,
<>
<Radio.Group
variant="outline"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>
<Radio.Group
variant="primary-filled"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>
<Radio.Group
variant="default-filled"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>
</>,
);
expect(container.firstChild.firstChild).toHaveClass('t-radio-button');
for (const item of container.children) {
expect(item.firstChild).toHaveClass('t-radio-button');
}
});

test('value is string', () => {
Expand Down
Loading

0 comments on commit 3e4564e

Please sign in to comment.