mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-13 23:37:47 +00:00
Avoid rounded with float numbers errors with javascript
0.7/0.001 = 699.9999999999999 Use Math.round() to avoid this.
This commit is contained in:
@@ -97,6 +97,13 @@ describe "Option Value Namer", ->
|
||||
p.variant_unit_scale = scale
|
||||
v.unit_value = 100 * scale
|
||||
expect(namer.option_value_value_unit()).toEqual [100, unit]
|
||||
|
||||
it "generates right values for volume with rounded values", ->
|
||||
unit = 'L'
|
||||
p.variant_unit = 'volume'
|
||||
p.variant_unit_scale = 1.0
|
||||
v.unit_value = 0.7
|
||||
expect(namer.option_value_value_unit()).toEqual [700, 'mL']
|
||||
|
||||
it "chooses the correct scale when value is very small", ->
|
||||
p.variant_unit = 'volume'
|
||||
|
||||
Reference in New Issue
Block a user