mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix unit value UI issue
This commit is contained in:
@@ -676,6 +676,15 @@ describe "AdminProductEditCtrl", ->
|
||||
unit_description: ''
|
||||
unit_value_with_description: "250,5"
|
||||
|
||||
it "rounds off the unit_value upto 8 decimal places and removes the trailing zeroes", ->
|
||||
testProduct = {id: 123, variant_unit_scale: 28.35}
|
||||
testVariant = {unit_value_with_description: "1234.5"}
|
||||
$scope.packVariant(testProduct, testVariant)
|
||||
expect(testVariant).toEqual
|
||||
unit_value: 34998.075
|
||||
unit_description: ''
|
||||
unit_value_with_description: "1234.5"
|
||||
|
||||
|
||||
describe "filtering products", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -152,6 +152,11 @@ describe "BulkProducts service", ->
|
||||
variant = {unit_value: 5}
|
||||
expect(BulkProducts.variantUnitValue(product, variant)).toEqual 5000
|
||||
|
||||
it "returns the scaled value rounded off upto 8 decimal points removing the trailing zeroes", ->
|
||||
product = {variant_unit_scale: 28.35}
|
||||
variant = {unit_value: 1234.5}
|
||||
expect(BulkProducts.variantUnitValue(product, variant)).toEqual 43.54497354
|
||||
|
||||
it "returns the unscaled value when the product has no scale", ->
|
||||
product = {}
|
||||
variant = {unit_value: 5}
|
||||
|
||||
Reference in New Issue
Block a user