Use new exchange products endpoint for outgoing exchanges and make the exchange products panel work for outgoing exchanges

This commit is contained in:
luisramos0
2019-11-14 19:26:11 +00:00
parent 89628c27f3
commit 24d7672abb
6 changed files with 3 additions and 57 deletions

View File

@@ -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')

View File

@@ -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])