From 3e4564ec0e38779d814f2588f018b0c935484c4f Mon Sep 17 00:00:00 2001 From: yijie4188 Date: Sun, 26 Nov 2023 04:15:37 +0800 Subject: [PATCH 1/2] fix(radio): group can't render outline variant by options prop --- src/radio/RadioGroup.tsx | 2 +- src/radio/__tests__/radio.test.tsx | 26 ++- test/snap/__snapshots__/csr.test.jsx.snap | 240 +++++++++++----------- test/snap/__snapshots__/ssr.test.jsx.snap | 8 +- 4 files changed, 145 insertions(+), 131 deletions(-) diff --git a/src/radio/RadioGroup.tsx b/src/radio/RadioGroup.tsx index 9032d3532d..9769141680 100644 --- a/src/radio/RadioGroup.tsx +++ b/src/radio/RadioGroup.tsx @@ -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; diff --git a/src/radio/__tests__/radio.test.tsx b/src/radio/__tests__/radio.test.tsx index 896ae94d17..aa26ecd8c9 100644 --- a/src/radio/__tests__/radio.test.tsx +++ b/src/radio/__tests__/radio.test.tsx @@ -81,13 +81,27 @@ describe('RadioGroup', () => { test('variant', () => { const { container } = render( - , + <> + + + + , ); - 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', () => { diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index a49e79852f..5af7812bc7 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -49234,42 +49234,42 @@ exports[`csr snapshot test > csr test src/collapse/_example/icon.jsx 1`] = ` class="t-radio-group t-size-m t-radio-group__outline" >