mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Merge pull request #5178 from coopdevs/dont-populate-empty-cart
Dont populate empty cart
This commit is contained in:
@@ -5,5 +5,9 @@ Darkswarm.directive "shopVariant", ->
|
||||
scope:
|
||||
variant: '='
|
||||
controller: ($scope, Cart) ->
|
||||
$scope.$watchGroup ['variant.line_item.quantity', 'variant.line_item.max_quantity'], ->
|
||||
$scope.$watchGroup [
|
||||
'variant.line_item.quantity',
|
||||
'variant.line_item.max_quantity'
|
||||
], (new_value, old_value) ->
|
||||
return if old_value[0] == null && new_value[0] == null
|
||||
Cart.adjust($scope.variant.line_item)
|
||||
|
||||
@@ -45,6 +45,13 @@ describe 'Cart service', ->
|
||||
Cart.adjust(order.line_items[0])
|
||||
expect(Cart.line_items.length).toEqual 0
|
||||
|
||||
it "does not add an item in the cart without quantity", ->
|
||||
Cart.line_items = []
|
||||
|
||||
spyOn(Cart, 'orderChanged')
|
||||
order.line_items[0].max_quantity = 0
|
||||
expect(Cart.orderChanged).not.toHaveBeenCalled()
|
||||
|
||||
it "sums the quantity of each line item for cart total", ->
|
||||
order.line_items[0].quantity = 2
|
||||
expect(Cart.total_item_count()).toEqual 2
|
||||
|
||||
Reference in New Issue
Block a user