WIP: Adding a side_menu to the enterprise form

This commit is contained in:
Rob Harrington
2014-11-28 12:05:01 +11:00
parent b0c86f83ee
commit 39ca0ce3dc
9 changed files with 102 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
describe "menuCtrl", ->
ctrl = null
scope = null
Enterprise = null
SideMenu = SideMenu
beforeEach ->
module('admin.enterprises')
Enterprise =
enterprise:
payment_method_ids: [ 1, 3 ]
shipping_method_ids: [ 2, 4 ]
# PaymentMethods =
# paymentMethods: [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ]
# ShippingMethods =
# shippingMethods: [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ]
inject ($controller, _SideMenu_) ->
scope = {}
SideMenu = _SideMenu_
spyOn(SideMenu, "select").andCallThrough()
spyOn(SideMenu, "setItems").andCallThrough()
ctrl = $controller 'sideMenuCtrl', {$scope: scope, Enterprise: Enterprise, SideMenu: SideMenu}
describe "initialisation", ->
it "stores enterprise", ->
expect(scope.Enterprise).toEqual Enterprise.enterprise
it "sets the item list", ->
expect(SideMenu.setItems).toHaveBeenCalled
expect(scope.menu).toBe SideMenu.items
it "sets the initally selected value", ->
expect(SideMenu.select).toHaveBeenCalledWith 0
describe "selecting an item", ->
it "selects an item by performing setting the selected property on the item to true", ->
scope.select 4
expect(SideMenu.select).toHaveBeenCalledWith 4
expect(scope.menu[4].selected).toBe true