mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
When submitting checkout, if field is invalid, show errors
This commit is contained in:
@@ -33,13 +33,28 @@ describe "CheckoutCtrl", ->
|
||||
spyOn(storage, "bind").andCallThrough()
|
||||
scope = $rootScope.$new()
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, Checkout: Checkout, CurrentUser: {}}
|
||||
|
||||
it "delegates to the service on submit", ->
|
||||
|
||||
describe "submitting", ->
|
||||
event =
|
||||
preventDefault: ->
|
||||
spyOn(Checkout, "submit")
|
||||
scope.purchase(event)
|
||||
expect(Checkout.submit).toHaveBeenCalled()
|
||||
|
||||
beforeEach ->
|
||||
spyOn(Checkout, "submit")
|
||||
scope.submitted = false
|
||||
|
||||
it "delegates to the service when valid", ->
|
||||
scope.checkout =
|
||||
$valid: true
|
||||
scope.purchase(event)
|
||||
expect(Checkout.submit).toHaveBeenCalled()
|
||||
expect(scope.submitted).toBe(true)
|
||||
|
||||
it "does nothing when invalid", ->
|
||||
scope.checkout =
|
||||
$valid: false
|
||||
scope.purchase(event)
|
||||
expect(Checkout.submit).not.toHaveBeenCalled()
|
||||
expect(scope.submitted).toBe(true)
|
||||
|
||||
it "is enabled", ->
|
||||
expect(scope.enabled).toEqual true
|
||||
|
||||
Reference in New Issue
Block a user