diff --git a/dist/index.js b/dist/index.js index c2b339f..bfb135b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -78,7 +78,7 @@ export default class AnimateNumber extends Component { // default values of state and non-state variables this.state = { value : 0, - displayValue : 0 + displayValue : props.formatter(0) } this.dirty = false; this.startFrom = 0; diff --git a/test/index.js b/test/index.js index 26be557..715ab0b 100644 --- a/test/index.js +++ b/test/index.js @@ -67,6 +67,15 @@ describe('', () => { mount() }) + it('is initial 0 value formatted ?', () => { + let props = { + value : 0, + formatter : (val) => `$ ${val} ^_^`, + } + let wrapper = mount() + expect(wrapper.state().displayValue).to.equal('$ 0 ^_^') + }) + it('does countBy prop works correctly ?', (done) => { let props = { value : Math.random() * 50,