Only show order cycle options that include the chosen distributor

This commit is contained in:
Rohan Mitchell
2015-12-04 12:16:45 +11:00
parent 2081744cf6
commit c74463404d
6 changed files with 52 additions and 15 deletions

View File

@@ -0,0 +1,28 @@
describe "ordersCtrl", ->
ctrl = null
scope = {}
attrs = {}
shops = []
orderCycles = [
{id: 10, distributors: [{id: 1, name: 'One'}]}
{id: 20, distributors: [{id: 2, name: 'Two'}]}
]
beforeEach ->
scope = {}
module('admin.orders')
inject ($controller) ->
ctrl = $controller 'ordersCtrl', {$scope: scope, $attrs: attrs, shops: shops, orderCycles: orderCycles}
describe "finding valid order cycles for a distributor", ->
order_cycle = {id: 10, distributors: [{id: 1, name: 'One'}]}
it "returns true when the order cycle includes the distributor", ->
scope.distributor_id = '1'
expect(scope.validOrderCycle(order_cycle, 1, [order_cycle])).toBe true
it "returns false otherwise", ->
scope.distributor_id = '2'
expect(scope.validOrderCycle(order_cycle, 1, [order_cycle])).toBe false