When BOM is 'item', do not update sumOfUnitValues with scale

since scale is always `1`, but return a value

+ update tests as well
This commit is contained in:
Jean-Baptiste Bellet
2022-04-25 15:53:38 +02:00
parent 3553cc0d9f
commit a4afeeaa3d
2 changed files with 9 additions and 12 deletions

View File

@@ -207,13 +207,7 @@ describe "LineItemsCtrl", ->
scope.selectedUnitsProduct = { variant_unit: "weight" }
expect(scope.fulfilled()).toEqual ''
it "returns '', and does not call Math.round if variant_unit is 'items'", ->
spyOn(Math,"round")
scope.selectedUnitsProduct = { variant_unit: "items", group_buy_unit_size: 10 }
expect(scope.fulfilled()).toEqual ''
expect(Math.round).not.toHaveBeenCalled()
it "calls Math.round() if variant_unit is 'weight' or 'volume'", ->
it "calls Math.round() if variant_unit is 'weight', 'volume', or items", ->
spyOn(Math,"round")
scope.selectedUnitsProduct = { variant_unit: "weight", group_buy_unit_size: 10 }
scope.fulfilled()
@@ -221,6 +215,9 @@ describe "LineItemsCtrl", ->
scope.selectedUnitsProduct = { variant_unit: "volume", group_buy_unit_size: 10 }
scope.fulfilled()
expect(Math.round).toHaveBeenCalled()
scope.selectedUnitsProduct = { variant_unit: "items", group_buy_unit_size: 10 }
scope.fulfilled()
expect(Math.round).toHaveBeenCalled()
describe "returns the quantity of fulfilled group buy units", ->