mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
Replace references to 'standing order' with 'subscription' (js: spec)
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
describe "StandingLineItemsCtrl", ->
|
||||
scope = null
|
||||
http = null
|
||||
standingOrder = { id: 1 }
|
||||
subscription = { id: 1 }
|
||||
standingLineItem = { id: 2, variant_id: 44 }
|
||||
|
||||
beforeEach ->
|
||||
module('admin.standingOrders')
|
||||
module('admin.subscriptions')
|
||||
|
||||
inject ($controller, $rootScope, $httpBackend) ->
|
||||
scope = $rootScope
|
||||
http = $httpBackend
|
||||
scope.standingOrder = standingOrder
|
||||
standingOrder.standing_line_items = [standingLineItem]
|
||||
scope.subscription = subscription
|
||||
subscription.standing_line_items = [standingLineItem]
|
||||
$controller 'StandingLineItemsController', {$scope: scope}
|
||||
|
||||
describe "match", ->
|
||||
@@ -31,8 +31,8 @@ describe "StandingLineItemsCtrl", ->
|
||||
|
||||
describe "addStandingLineItem", ->
|
||||
beforeEach ->
|
||||
scope.standing_order_form = jasmine.createSpyObj('standing_order_form', ['$setDirty'])
|
||||
standingOrder.buildItem = jasmine.createSpy('buildItem')
|
||||
scope.subscription_form = jasmine.createSpyObj('subscription_form', ['$setDirty'])
|
||||
subscription.buildItem = jasmine.createSpy('buildItem')
|
||||
|
||||
describe "when an item with a matching variant_id is found", ->
|
||||
match = null
|
||||
@@ -65,7 +65,7 @@ describe "StandingLineItemsCtrl", ->
|
||||
beforeEach ->
|
||||
spyOn(scope, "match").and.returnValue(null)
|
||||
|
||||
it "sets the form to $dirty and called buildItem on scope.standingOrder", ->
|
||||
it "sets the form to $dirty and called buildItem on scope.subscription", ->
|
||||
scope.addStandingLineItem()
|
||||
expect(scope.standing_order_form.$setDirty).toHaveBeenCalled()
|
||||
expect(standingOrder.buildItem).toHaveBeenCalledWith(scope.newItem)
|
||||
expect(scope.subscription_form.$setDirty).toHaveBeenCalled()
|
||||
expect(subscription.buildItem).toHaveBeenCalledWith(scope.newItem)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe "StandingOrdersCtrl", ->
|
||||
describe "SubscriptionsCtrl", ->
|
||||
scope = null
|
||||
http = null
|
||||
shops = [
|
||||
@@ -8,16 +8,16 @@ describe "StandingOrdersCtrl", ->
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
module('admin.standingOrders')
|
||||
module('admin.subscriptions')
|
||||
module ($provide) ->
|
||||
# $provide.value 'columns', []
|
||||
$provide.value 'shops', shops
|
||||
null
|
||||
|
||||
inject ($controller, $rootScope, _StandingOrderResource_, $httpBackend) ->
|
||||
inject ($controller, $rootScope, _SubscriptionResource_, $httpBackend) ->
|
||||
scope = $rootScope
|
||||
http = $httpBackend
|
||||
$controller 'StandingOrdersController', {$scope: scope, StandingOrderResource: _StandingOrderResource_}
|
||||
$controller 'SubscriptionsController', {$scope: scope, SubscriptionResource: _SubscriptionResource_}
|
||||
jasmine.addMatchers
|
||||
toDeepEqual: (util, customEqualityTesters) ->
|
||||
compare: (actual, expected) ->
|
||||
@@ -27,16 +27,16 @@ describe "StandingOrdersCtrl", ->
|
||||
expect(scope.shop_id).toEqual null
|
||||
|
||||
describe "setting shop_id on scope", ->
|
||||
standingOrder = { errors: {}, id: 5, customer_id: 3, schedule_id: 1 }
|
||||
standingOrders = [standingOrder]
|
||||
subscription = { errors: {}, id: 5, customer_id: 3, schedule_id: 1 }
|
||||
subscriptions = [subscription]
|
||||
|
||||
beforeEach ->
|
||||
http.expectGET('/admin/standing_orders.json?q%5Bcanceled_at_null%5D=true&q%5Bshop_id_eq%5D=3').respond 200, standingOrders
|
||||
http.expectGET('/admin/subscriptions.json?q%5Bcanceled_at_null%5D=true&q%5Bshop_id_eq%5D=3').respond 200, subscriptions
|
||||
scope.$apply -> scope.shop_id = 3
|
||||
http.flush()
|
||||
|
||||
# it "sets the CurrentShop", inject (CurrentShop) ->
|
||||
# expect(CurrentShop.shop).toEqual shops[2]
|
||||
|
||||
it "retrieves the list of standingOrders", ->
|
||||
expect(scope.standingOrders).toDeepEqual standingOrders
|
||||
it "retrieves the list of subscriptions", ->
|
||||
expect(scope.subscriptions).toDeepEqual subscriptions
|
||||
|
||||
Reference in New Issue
Block a user