mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-23 01:03:21 +00:00
Merge branch 'master' of github.com:openfoodfoundation/openfoodnetwork into bulk-product-edit
This commit is contained in:
@@ -350,6 +350,33 @@ describe "AdminOrderMgmtCtrl", ->
|
||||
spyOn(VariantUnitManager, "getUnitName").andReturn "kg"
|
||||
expect(scope.formattedValueWithUnitName(2000,unitsVariant)).toEqual "2 kg"
|
||||
|
||||
describe "updating the price upon updating the weight of a line item", ->
|
||||
|
||||
it "resets the weight if the weight is set to zero", ->
|
||||
scope.filteredLineItems = [
|
||||
{ units_variant: { unit_value: 100 }, price: 2, unit_value: 0 }
|
||||
]
|
||||
expect(scope.weightAdjustedPrice(scope.filteredLineItems[0], 100)).toEqual scope.filteredLineItems[0].price
|
||||
|
||||
it "updates the price if the weight is changed", ->
|
||||
scope.filteredLineItems = [
|
||||
{ units_variant: { unit_value: 100 }, price: 2, unit_value: 200 }
|
||||
]
|
||||
old_value = scope.filteredLineItems[0].units_variant.unit_value
|
||||
new_value = scope.filteredLineItems[0].unit_value
|
||||
sp = scope.filteredLineItems[0].price * new_value / old_value
|
||||
expect(scope.weightAdjustedPrice(scope.filteredLineItems[0], old_value)).toEqual sp
|
||||
|
||||
it "doesn't update the price if the weight is not changed", ->
|
||||
scope.filteredLineItems = [
|
||||
{ units_variant: { unit_value: 100 }, price: 2, unit_value: 100 }
|
||||
]
|
||||
old_value = scope.filteredLineItems[0].unit_value
|
||||
new_value = scope.filteredLineItems[0].unit_value
|
||||
sp = scope.filteredLineItems[0].price
|
||||
expect(scope.weightAdjustedPrice(scope.filteredLineItems[0], old_value)).toEqual sp
|
||||
|
||||
|
||||
describe "managing pending changes", ->
|
||||
dataSubmitter = pendingChangesService = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user