Skip to content

Commit 5658be6

Browse files
committed
Fixed issue #33
1 parent 7a2ac60 commit 5658be6

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

examples/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
</head>
1111
<body>
1212

13+
<div id="example0" style="margin: 10px">2</div>
14+
15+
1316
<div id="example1" style="margin: 10px">2</div>
1417

1518

examples/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ReactDOM from 'react-dom';
88
import CurrencyInput from '../src/index';
99

1010

11+
ReactDOM.render(<CurrencyInput value={0.0}/>, document.getElementById('example0'));
1112

1213
ReactDOM.render(<CurrencyInput suffix=" kr"/>, document.getElementById('example1'));
1314

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CurrencyInput extends Component {
4444
delete customProps.suffix;
4545

4646
let initialValue = props.value;
47-
if (!initialValue) {
47+
if (initialValue === null) {
4848
initialValue = props.allowEmpty? null : '';
4949
}else{
5050

test/index.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ describe('react-currency-input', function(){
101101
expect (renderedComponent.getMaskedValue()).to.equal('1,234,568')
102102
});
103103

104+
it('it handles initial value as the integer 0,', function() {
105+
var renderedComponent = ReactTestUtils.renderIntoDocument(
106+
<CurrencyInput value={0} />
107+
);
108+
expect (renderedComponent.getMaskedValue()).to.equal('0.00')
109+
});
110+
111+
it('it handles initial value as the float 0.00,', function() {
112+
var renderedComponent = ReactTestUtils.renderIntoDocument(
113+
<CurrencyInput value={0.00} />
114+
);
115+
expect (renderedComponent.getMaskedValue()).to.equal('0.00')
116+
});
117+
104118
});
105119

106120

0 commit comments

Comments
 (0)