mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 12:38:58 +08:00
commit
0d8fa8d1dd
@ -30,7 +30,7 @@ const StatisticNumber: React.FC<NumberProps> = props => {
|
||||
int = int.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
|
||||
|
||||
if (typeof precision === 'number') {
|
||||
decimal = padEnd(decimal, precision, '0').slice(0, precision);
|
||||
decimal = padEnd(decimal, precision, '0').slice(0, precision > 0 ? precision : 0);
|
||||
}
|
||||
|
||||
if (decimal) {
|
||||
|
@ -51,6 +51,20 @@ describe('Statistic', () => {
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('allow negetive precision', () => {
|
||||
[
|
||||
[-1, -1112893.1212, '-1,112,893'],
|
||||
[-2, -1112893.1212, '-1,112,893'],
|
||||
[-3, -1112893.1212, '-1,112,893'],
|
||||
[-1, -1112893, '-1,112,893'],
|
||||
[-1, 1112893, '1,112,893'],
|
||||
].forEach(([precision, value, expectValue]) => {
|
||||
const wrapper = mount(<Statistic precision={precision} value={value} />);
|
||||
expect(wrapper.find('.ant-statistic-content-value-int').text()).toEqual(expectValue);
|
||||
expect(wrapper.find('.ant-statistic-content-value-decimal').length).toBe(0);
|
||||
})
|
||||
});
|
||||
|
||||
it('loading with skeleton', async () => {
|
||||
let loading = false;
|
||||
const wrapper = mount(<Statistic title="Active Users" value={112112} loading={loading} />);
|
||||
|
Loading…
Reference in New Issue
Block a user