Automatically closing the accordion if the form is already valid

This commit is contained in:
Will Marshall
2014-05-30 11:58:22 +10:00
parent dd0907addd
commit 1a47a7486e
5 changed files with 41 additions and 23 deletions

View File

@@ -1,19 +1,40 @@
describe "AccordionCtrl", ->
ctrl = null
scope = scope
scope = null
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
describe "loading incomplete form", ->
beforeEach ->
inject ($controller, $rootScope) ->
scope = $rootScope.$new()
scope.order =
id: 129
ctrl = $controller 'AccordionCtrl', {$scope: scope}
it "changes accordion", ->
scope.show "shipping"
expect(scope.accordion["shipping"]).toEqual true
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
describe "loading complete form", ->
beforeEach ->
inject ($controller, $rootScope) ->
scope = $rootScope.$new()
scope.checkout =
$valid: true
scope.order =
id: 129
ctrl = $controller 'AccordionCtrl', {$scope: scope}
it "automatically closes all sections if the entire form is valid", ->
waitsFor ->
(scope.accordion.details and
scope.accordion.shipping and
scope.accordion.payment and
scope.accordion.billing) == false
, "the accordion to close", 100