chore: auto merge branchs (#35532)

chore: feature merge master
This commit is contained in:
github-actions[bot] 2022-05-13 03:59:13 +00:00 committed by GitHub
commit 0d8fa8d1dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -30,7 +30,7 @@ const StatisticNumber: React.FC<NumberProps> = props => {
int = int.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator); int = int.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
if (typeof precision === 'number') { 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) { if (decimal) {

View File

@ -51,6 +51,20 @@ describe('Statistic', () => {
expect(wrapper.render()).toMatchSnapshot(); 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 () => { it('loading with skeleton', async () => {
let loading = false; let loading = false;
const wrapper = mount(<Statistic title="Active Users" value={112112} loading={loading} />); const wrapper = mount(<Statistic title="Active Users" value={112112} loading={loading} />);