mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Handle null/undefined cases for price
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
angular.module("admin.utils").filter "unlocalizeCurrency", ()->
|
||||
# Convert string to number using injected currency configuration.
|
||||
(price) ->
|
||||
if (!price)
|
||||
return null
|
||||
# used decimal and thousands separators from currency configuration
|
||||
decimal_separator = I18n.toCurrency(.1, {precision: 1, unit: ''}).substring(1,2)
|
||||
thousands_separator = I18n.toCurrency(1000, {precision: 1, unit: ''}).substring(1,2)
|
||||
|
||||
@@ -89,3 +89,10 @@ describe 'convert string to number with configurated currency', ->
|
||||
|
||||
it "handle integer number with no thousands separator", ->
|
||||
expect(filter("1000")).toEqual 1000
|
||||
|
||||
describe "handle null/undefined case", ->
|
||||
it "null case", ->
|
||||
expect(filter(null)).toEqual null
|
||||
|
||||
it "undefined case ", ->
|
||||
expect(filter(undefined)).toEqual null
|
||||
|
||||
Reference in New Issue
Block a user