mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Splitting out the accordion stuff for checkout
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
describe "AccordionCtrl", ->
|
||||
ctrl = null
|
||||
scope = scope
|
||||
|
||||
beforeEach ->
|
||||
module "Darkswarm"
|
||||
localStorage.clear()
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope.$new()
|
||||
scope.order =
|
||||
id: 129
|
||||
ctrl = $controller 'AccordionCtrl', {$scope: scope}
|
||||
|
||||
it "defaults the details accordion to visible", ->
|
||||
expect(scope.accordion.details).toEqual true
|
||||
|
||||
it "changes accordion", ->
|
||||
scope.show "shipping"
|
||||
expect(scope.accordion["shipping"]).toEqual true
|
||||
@@ -0,0 +1,39 @@
|
||||
describe "CheckoutCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
Order = null
|
||||
CurrentUser = null
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
angular.module('Darkswarm').value('user', {})
|
||||
Order =
|
||||
submit: ->
|
||||
navigate: ->
|
||||
order:
|
||||
id: 1
|
||||
|
||||
describe "with user", ->
|
||||
beforeEach ->
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope.$new()
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, Order: Order, CurrentUser: {}}
|
||||
|
||||
it "delegates to the service on submit", ->
|
||||
event =
|
||||
preventDefault: ->
|
||||
spyOn(Order, "submit")
|
||||
scope.purchase(event)
|
||||
expect(Order.submit).toHaveBeenCalled()
|
||||
|
||||
it "is enabled", ->
|
||||
expect(scope.enabled).toEqual true
|
||||
|
||||
describe "without user", ->
|
||||
beforeEach ->
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope.$new()
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, Order: Order, CurrentUser: undefined}
|
||||
|
||||
it "is disabled", ->
|
||||
expect(scope.enabled).toEqual false
|
||||
@@ -1,28 +0,0 @@
|
||||
describe "CheckoutCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
Order = null
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
angular.module('Darkswarm').value('user', {})
|
||||
Order = {
|
||||
submit: ->
|
||||
navigate: ->
|
||||
order:
|
||||
id: 1
|
||||
}
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope.$new()
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, Order: Order}
|
||||
|
||||
it "defaults the user accordion to visible", ->
|
||||
expect(scope.accordion.user).toEqual true
|
||||
|
||||
it "delegates to the service on submit", ->
|
||||
event = {
|
||||
preventDefault: ->
|
||||
}
|
||||
spyOn(Order, "submit")
|
||||
scope.purchase(event)
|
||||
expect(Order.submit).toHaveBeenCalled()
|
||||
Reference in New Issue
Block a user