mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
45 lines
1.1 KiB
CoffeeScript
45 lines
1.1 KiB
CoffeeScript
describe "CheckoutCtrl", ->
|
|
ctrl = null
|
|
scope = null
|
|
order = null
|
|
|
|
beforeEach ->
|
|
module("Darkswarm")
|
|
order = {
|
|
submit: ->
|
|
}
|
|
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()
|
|
|
|
it "finds a field by path", ->
|
|
scope.checkout =
|
|
path: "test"
|
|
expect(scope.field('path')).toEqual "test"
|
|
|
|
it "tests validity", ->
|
|
scope.checkout =
|
|
path:
|
|
$dirty: true
|
|
$invalid: true
|
|
expect(scope.fieldValid('path')).toEqual false
|
|
|
|
it "returns errors by path", ->
|
|
scope.checkout =
|
|
path:
|
|
$error:
|
|
email: true
|
|
required: true
|
|
expect(scope.fieldErrors('path')).toEqual ["must be email address", "must not be blank"].join ", "
|