mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-03 22:06:07 +00:00
Use new exchange products endpoint for outgoing exchanges and make the exchange products panel work for outgoing exchanges
This commit is contained in:
@@ -14,7 +14,6 @@ describe 'AdminOrderCycleOutgoingCtrl', ->
|
||||
absUrl: ->
|
||||
'example.com/admin/order_cycles/27/edit'
|
||||
OrderCycle =
|
||||
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').and.returnValue('product supplied')
|
||||
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').and.returnValue('variant supplied')
|
||||
ocInstance = {}
|
||||
|
||||
@@ -22,10 +21,6 @@ describe 'AdminOrderCycleOutgoingCtrl', ->
|
||||
inject ($controller) ->
|
||||
ctrl = $controller 'AdminOrderCycleOutgoingCtrl', {$scope: scope, $location: location, OrderCycle: OrderCycle, Enterprise: Enterprise, EnterpriseFee: EnterpriseFee, ocInstance: ocInstance}
|
||||
|
||||
it 'Delegates productSuppliedToOrderCycle to OrderCycle', ->
|
||||
expect(scope.productSuppliedToOrderCycle('product')).toEqual('product supplied')
|
||||
expect(OrderCycle.productSuppliedToOrderCycle).toHaveBeenCalledWith('product')
|
||||
|
||||
it 'Delegates variantSuppliedToOrderCycle to OrderCycle', ->
|
||||
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
|
||||
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
|
||||
|
||||
@@ -232,42 +232,6 @@ describe 'OrderCycle service', ->
|
||||
]
|
||||
expect(OrderCycle.incomingExchangesVariants()).toEqual [1, 4, 5]
|
||||
|
||||
describe 'checking whether a product is supplied to the order cycle', ->
|
||||
product_master_present = product_variant_present = product_master_absent = product_variant_absent = null
|
||||
|
||||
beforeEach ->
|
||||
product_master_present =
|
||||
name: "Linseed (500g)"
|
||||
master_id: 1
|
||||
variants: []
|
||||
product_variant_present =
|
||||
name: "Linseed (500g)"
|
||||
master_id: 2
|
||||
variants: [{id: 3}, {id: 4}]
|
||||
product_master_absent =
|
||||
name: "Linseed (500g)"
|
||||
master_id: 5
|
||||
variants: []
|
||||
product_variant_absent =
|
||||
name: "Linseed (500g)"
|
||||
master_id: 6
|
||||
variants: [{id: 7}, {id: 8}]
|
||||
|
||||
spyOn(OrderCycle, 'incomingExchangesVariants').and.returnValue([1, 3])
|
||||
|
||||
it 'returns true for products whose master is supplied', ->
|
||||
expect(OrderCycle.productSuppliedToOrderCycle(product_master_present)).toBeTruthy()
|
||||
|
||||
it 'returns true for products for whom a variant is supplied', ->
|
||||
expect(OrderCycle.productSuppliedToOrderCycle(product_variant_present)).toBeTruthy()
|
||||
|
||||
it 'returns false for products whose master is not supplied', ->
|
||||
expect(OrderCycle.productSuppliedToOrderCycle(product_master_absent)).toBeFalsy()
|
||||
|
||||
it 'returns false for products whose variants are not supplied', ->
|
||||
expect(OrderCycle.productSuppliedToOrderCycle(product_variant_absent)).toBeFalsy()
|
||||
|
||||
|
||||
describe 'checking whether a variant is supplied to the order cycle', ->
|
||||
beforeEach ->
|
||||
spyOn(OrderCycle, 'incomingExchangesVariants').and.returnValue([1, 3])
|
||||
|
||||
Reference in New Issue
Block a user