mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
fix: Statistic show -0 (#22950)
This commit is contained in:
parent
69daa6fea7
commit
5c4db907c5
@ -20,7 +20,7 @@ const StatisticNumber: React.FC<NumberProps> = props => {
|
|||||||
const cells = val.match(/^(-?)(\d*)(\.(\d+))?$/);
|
const cells = val.match(/^(-?)(\d*)(\.(\d+))?$/);
|
||||||
|
|
||||||
// Process if illegal number
|
// Process if illegal number
|
||||||
if (!cells) {
|
if (!cells || val === '-') {
|
||||||
valueNode = val;
|
valueNode = val;
|
||||||
} else {
|
} else {
|
||||||
const negative = cells[1];
|
const negative = cells[1];
|
||||||
|
@ -21,6 +21,11 @@ describe('Statistic', () => {
|
|||||||
MockDate.reset();
|
MockDate.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('`-` is not a number', () => {
|
||||||
|
const wrapper = mount(<Statistic value="-" />);
|
||||||
|
expect(wrapper.find('.ant-statistic-content').text()).toEqual('-');
|
||||||
|
});
|
||||||
|
|
||||||
it('customize formatter', () => {
|
it('customize formatter', () => {
|
||||||
const formatter = jest.fn(() => 93);
|
const formatter = jest.fn(() => 93);
|
||||||
const wrapper = mount(<Statistic value={1128} formatter={formatter} />);
|
const wrapper = mount(<Statistic value={1128} formatter={formatter} />);
|
||||||
@ -47,12 +52,7 @@ describe('Statistic', () => {
|
|||||||
|
|
||||||
describe('Countdown', () => {
|
describe('Countdown', () => {
|
||||||
it('render correctly', () => {
|
it('render correctly', () => {
|
||||||
const now = moment()
|
const now = moment().add(2, 'd').add(11, 'h').add(28, 'm').add(9, 's').add(3, 'ms');
|
||||||
.add(2, 'd')
|
|
||||||
.add(11, 'h')
|
|
||||||
.add(28, 'm')
|
|
||||||
.add(9, 's')
|
|
||||||
.add(3, 'ms');
|
|
||||||
|
|
||||||
[
|
[
|
||||||
['H:m:s', '59:28:9'],
|
['H:m:s', '59:28:9'],
|
||||||
|
Loading…
Reference in New Issue
Block a user