Creating basic angular StripeJS wrapper service for requesting tokens

This commit is contained in:
Rob Harrington
2017-02-21 12:25:51 +11:00
parent 5ad88f992c
commit 5c16fefe41
6 changed files with 162 additions and 26 deletions

View File

@@ -16,6 +16,7 @@ describe "CheckoutCtrl", ->
$provide.value "CurrentHub", CurrentHubMock
null
Checkout =
purchase: ->
submit: ->
navigate: ->
bindFieldsToLocalStorage: ->
@@ -42,17 +43,17 @@ describe "CheckoutCtrl", ->
preventDefault: ->
beforeEach ->
spyOn(Checkout, "submit")
spyOn(Checkout, "purchase")
scope.submitted = false
it "delegates to the service when valid", ->
scope.purchase(event, {$valid: true})
expect(Checkout.submit).toHaveBeenCalled()
expect(Checkout.purchase).toHaveBeenCalled()
expect(scope.submitted).toBe(true)
it "does nothing when invalid", ->
scope.purchase(event, {$valid: false})
expect(Checkout.submit).not.toHaveBeenCalled()
expect(Checkout.purchase).not.toHaveBeenCalled()
expect(scope.submitted).toBe(true)
it "is enabled", ->