Add unit tests for AdminCreateOrderCycleCtrl angular controller

This commit is contained in:
Rohan Mitchell
2012-12-05 16:09:20 +11:00
parent 55423d2df1
commit 0a6686b592
12 changed files with 440 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
describe 'OrderCycle controllers', ->
describe 'AdminCreateOrderCycleCtrl', ->
ctrl = null
scope = null
OrderCycle = null
Enterprise = null
beforeEach ->
scope = {}
OrderCycle =
order_cycle: 'my order cycle'
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
create: jasmine.createSpy('create')
Enterprise =
index: jasmine.createSpy('index')
ctrl = new AdminCreateOrderCycleCtrl(scope, OrderCycle, Enterprise)
it 'Loads enterprises', ->
expect(Enterprise.index).toHaveBeenCalled()
it 'Loads order cycles', ->
expect(scope.order_cycle).toEqual('my order cycle')
it 'Delegates toggleProducts to OrderCycle', ->
scope.toggleProducts('event', 'exchange')
expect(OrderCycle.toggleProducts).toHaveBeenCalledWith('event', 'exchange')
it 'Adds order cycle suppliers', ->
scope.new_supplier_id = 'new supplier id'
scope.addSupplier('event')
expect(OrderCycle.addSupplier).toHaveBeenCalledWith('event', 'new supplier id')
it 'Submits the order cycle via OrderCycle create', ->
scope.submit()
expect(OrderCycle.create).toHaveBeenCalled()
describe 'AdminEditOrderCycleCtrl', ->
describe 'OrderCycle services', ->
describe 'OrderCycle directives', ->