Skip to content

Commit 1ea3f2d

Browse files
Kevin OngkoKevin Ongko
Kevin Ongko
authored and
Kevin Ongko
committed
2.2.3
1 parent 5ae893f commit 1ea3f2d

File tree

6 files changed

+237
-143
lines changed

6 files changed

+237
-143
lines changed

dist/vue-numeric.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ <h1 class="title is-4">
126126

127127
<script src="https://unpkg.com/accounting-js"></script>
128128
<script src="https://unpkg.com/vue"></script>
129-
<script src="https://unpkg.com/vue-numeric"></script>
129+
<script src="../dist/vue-numeric.min.js"></script>
130130

131131
<script>
132132
Vue.use(VueNumeric.default)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-numeric",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "Input field component to display currency value based on Vue.",
55
"author": "Kevin Ongko",
66
"main": "dist/vue-numeric.min.js",

src/vue-numeric.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,13 @@ export default {
183183
*/
184184
onFocusHandler (e) {
185185
this.$emit('focus', e)
186-
this.amount = this.valueNumber
186+
this.amount = accounting.formatMoney(this.valueNumber, {
187+
symbol: '',
188+
format: '%v',
189+
thousand: '',
190+
decimal: this.decimalSeparator,
191+
precision: Number(this.precision)
192+
})
187193
},
188194
189195
/**

test/specs/vue-numeric.spec.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,25 @@ describe('vue-numeric.vue', () => {
161161
expect(wrapper.data().amount).to.equal('2,000')
162162
})
163163

164-
it('trigger onBlurHandler', () => {
164+
it('format value on blur', () => {
165165
const wrapper = mount(VueNumeric, {propsData: { value: 2000 }})
166166
wrapper.trigger('blur')
167167
expect(wrapper.data().amount).to.equal('2,000')
168168
})
169169

170-
it('trigger onFocusHandler', () => {
171-
const wrapper = mount(VueNumeric, {propsData: { value: 2000 }})
170+
it('remove thousand separator and symbol on focus with , decimal', () => {
171+
const wrapper = mount(VueNumeric, {propsData: { value: 2000.21, separator: '.', precision: 2 }})
172+
wrapper.trigger('focus')
173+
expect(wrapper.data().amount).to.equal('2000,21')
174+
})
175+
176+
it('remove thousand separator and symbol on focus with . decimal', () => {
177+
const wrapper = mount(VueNumeric, {propsData: { value: 2000.21, separator: ',', precision: 2 }})
172178
wrapper.trigger('focus')
173-
expect(wrapper.data().amount).to.equal(2000)
179+
expect(wrapper.data().amount).to.equal('2000.21')
174180
})
175181

176-
it('trigger onInputHandler', () => {
182+
it('process value on input', () => {
177183
const process = sinon.stub()
178184
const wrapper = mount(VueNumeric, { propsData: { value: 2000 }, methods: { process }})
179185
wrapper.trigger('input')

0 commit comments

Comments
 (0)