SO Index: User must select a shop first in order to load relevant standing orders

This commit is contained in:
Rob Harrington
2016-10-07 14:46:15 +11:00
parent a94742e4db
commit bbd43f7026
6 changed files with 58 additions and 32 deletions

View File

@@ -1,19 +1,18 @@
describe "StandingOrdersCtrl", ->
scope = null
http = null
shops = null
shops = [
{ name: "Shop 1", id: 1 }
{ name: "Shop 2", id: 2 }
{ name: "Shop 3", id: 3 }
]
beforeEach ->
module('admin.standingOrders')
# module ($provide) ->
# $provide.value 'columns', []
# null
# shops = [
# { name: "Shop 1", id: 1 }
# { name: "Shop 2", id: 2 }
# { name: "Shop 3", id: 3 }
# ]
module ($provide) ->
# $provide.value 'columns', []
$provide.value 'shops', shops
null
inject ($controller, $rootScope, _StandingOrderResource_, $httpBackend) ->
scope = $rootScope
@@ -24,28 +23,20 @@ describe "StandingOrdersCtrl", ->
compare: (actual, expected) ->
{ pass: angular.equals(actual, expected) }
# it "has no shop pre-selected", inject (CurrentShop) ->
# expect(CurrentShop.shop).toEqual {}
it "has no shop pre-selected", ->
expect(scope.shop_id).toEqual null
describe "initialization", -> # setting shop_id on scope
describe "setting shop_id on scope", ->
standingOrder = { id: 5, customer_id: 3, schedule_id: 1}
standingOrders = [standingOrder]
beforeEach inject ->
scope.standing_orders_form = jasmine.createSpyObj('standing_orders_form', ['$setPristine'])
http.expectGET('/admin/standing_orders.json?ams_prefix=index').respond 200, standingOrders
# scope.$apply ->
# scope.shop_id = 3
beforeEach ->
http.expectGET('/admin/standing_orders.json?ams_prefix=index&q%5Bshop_id_eq%5D=3').respond 200, standingOrders
scope.$apply -> scope.shop_id = 3
http.flush()
# it "sets the CurrentShop", inject (CurrentShop) ->
# expect(CurrentShop.shop).toEqual shops[2]
#
# it "sets the form state to pristine", ->
# expect(scope.standingOrders_form.$setPristine).toHaveBeenCalled()
#
# it "clears all changes", inject (pendingChanges) ->
# expect(pendingChanges.removeAll).toHaveBeenCalled()
it "retrieves the list of standingOrders", ->
expect(scope.standingOrders).toDeepEqual standingOrders