Splitting out the accordion stuff for checkout

This commit is contained in:
Will Marshall
2014-05-08 16:07:56 +10:00
parent 6696b8e17b
commit 3b1fcca39b
10 changed files with 107 additions and 84 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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()