OrderCycle can fetch the direction of an exchange (incoming/outgoing)

This commit is contained in:
Rohan Mitchell
2013-08-14 14:04:42 +10:00
parent a3970dde8a
commit e6fdcf581a
2 changed files with 32 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ describe 'OrderCycle controllers', ->
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').andReturn('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').andReturn('variant supplied')
exchangeDirection: jasmine.createSpy('exchangeDirection').andReturn('exchange direction')
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
@@ -66,6 +67,10 @@ describe 'OrderCycle controllers', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates exchangeDirection to OrderCycle', ->
expect(scope.exchangeDirection('exchange')).toEqual('exchange direction')
expect(OrderCycle.exchangeDirection).toHaveBeenCalledWith('exchange')
it 'Finds enterprises participating in the order cycle', ->
scope.enterprises =
1: {id: 1, name: 'Eaterprises'}
@@ -141,6 +146,7 @@ describe 'OrderCycle controllers', ->
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').andReturn('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').andReturn('variant supplied')
exchangeDirection: jasmine.createSpy('exchangeDirection').andReturn('exchange direction')
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
@@ -189,6 +195,10 @@ describe 'OrderCycle controllers', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates exchangeDirection to OrderCycle', ->
expect(scope.exchangeDirection('exchange')).toEqual('exchange direction')
expect(OrderCycle.exchangeDirection).toHaveBeenCalledWith('exchange')
it 'Finds enterprises participating in the order cycle', ->
scope.enterprises =
1: {id: 1, name: 'Eaterprises'}
@@ -350,6 +360,19 @@ describe 'OrderCycle services', ->
result = OrderCycle.exchangeSelectedVariants({variants: {1: true, 2: false, 3: true}})
expect(result).toEqual(2)
describe 'fetching the direction for an exchange', ->
it 'returns "incoming" for incoming exchanges', ->
exchange = {id: 1}
OrderCycle.order_cycle.incoming_exchanges = [exchange]
OrderCycle.order_cycle.outgoing_exchanges = []
expect(OrderCycle.exchangeDirection(exchange)).toEqual 'incoming'
it 'returns "outgoing" for outgoing exchanges', ->
exchange = {id: 1}
OrderCycle.order_cycle.incoming_exchanges = []
OrderCycle.order_cycle.outgoing_exchanges = [exchange]
expect(OrderCycle.exchangeDirection(exchange)).toEqual 'outgoing'
describe 'toggling products', ->
exchange = null