mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Handle comma as decimal separator in the unit value field
- Add comma as a decimal separator in the regexp - Do not use parseFloat but our `unlocalizeCurrencyFilter` which is more tolerant
This commit is contained in:
@@ -75,3 +75,21 @@ describe "unitsCtrl", ->
|
||||
scope.processUnitValueWithDescription()
|
||||
expect(scope.product.master.unit_value).toEqual 123
|
||||
expect(scope.product.master.unit_description).toEqual "54 boxes"
|
||||
|
||||
it "handle final point as decimal separator", ->
|
||||
scope.product.master.unit_value_with_description = "22.22"
|
||||
scope.processUnitValueWithDescription()
|
||||
expect(scope.product.master.unit_value).toEqual 22.22
|
||||
expect(scope.product.master.unit_description).toEqual ""
|
||||
|
||||
it "handle comma as decimal separator", ->
|
||||
scope.product.master.unit_value_with_description = "22,22"
|
||||
scope.processUnitValueWithDescription()
|
||||
expect(scope.product.master.unit_value).toEqual 22.22
|
||||
expect(scope.product.master.unit_description).toEqual ""
|
||||
|
||||
it "handle comma as decimal separator with description", ->
|
||||
scope.product.master.unit_value_with_description = "22,22 things"
|
||||
scope.processUnitValueWithDescription()
|
||||
expect(scope.product.master.unit_value).toEqual 22.22
|
||||
expect(scope.product.master.unit_description).toEqual "things"
|
||||
|
||||
Reference in New Issue
Block a user