From 7a4cbf2c36b1da44773e4b560a72dc12a4055d80 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Mon, 21 Feb 2022 20:01:27 +0800 Subject: [PATCH] fix: should display text properly if text is number 0 --- src/OptionList.tsx | 15 ++++----------- tests/Select.test.tsx | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/OptionList.tsx b/src/OptionList.tsx index 4162743bd..9de61eae5 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -31,16 +31,8 @@ const OptionList: React.ForwardRefRenderFunction { - const { - prefixCls, - id, - open, - multiple, - searchValue, - toggleOpen, - notFoundContent, - onPopupScroll, - } = useBaseProps(); + const { prefixCls, id, open, multiple, searchValue, toggleOpen, notFoundContent, onPopupScroll } = + useBaseProps(); const { flattenOptions, onActiveValue, @@ -306,7 +298,8 @@ const OptionList: React.ForwardRefRenderFunction { jest.useRealTimers(); }); + it('should render 0 as text properly', () => { + const data = [ + { text: 0, value: '=0' }, + { text: 1, value: '=1' }, + ]; + + const wrapper = mount( + , + ); + + expect(wrapper.find('.rc-select-item-option-content').first().text()).toEqual('0'); + }); + describe('focus', () => { let handleFocus; let wrapper;