Add test for unlocalize currency filter

- Test that comma is well handle in both cases where comma is the default decimal separator or not.
This commit is contained in:
Jean-Baptiste Bellet
2021-05-17 15:49:48 +02:00
parent f97e71d054
commit d8042b25e4

View File

@@ -0,0 +1,29 @@
describe 'convert string to number with configurated currency', ->
filter = null
beforeEach ->
module 'ofn.admin'
inject ($filter) ->
filter = $filter('unlocalizeCurrency')
describe "with point as decimal separator for I18n service", ->
beforeEach ->
spyOn(I18n, "toCurrency").and.returnValue "0.1"
it "handle point as decimal separator", ->
expect(filter("1.0")).toEqual 1.0
it "handle comma as decimal separator", ->
expect(filter("1,0")).toEqual 1.0
describe "with comma as decimal separator for I18n service", ->
beforeEach ->
spyOn(I18n, "toCurrency").and.returnValue "0,1"
it "handle point as decimal separator", ->
expect(filter("1.0")).toEqual 1.0
it "handle comma as decimal separator", ->
expect(filter("1,0")).toEqual 1.0