mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Working with ngForm and subcontrollers. Also fixing bulk order specs
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
describe "DetailsCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
order = null
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope.$new()
|
||||
ctrl = $controller 'DetailsCtrl', {$scope: scope}
|
||||
|
||||
|
||||
it "finds a field by path", ->
|
||||
scope.details =
|
||||
path: "test"
|
||||
expect(scope.field('path')).toEqual "test"
|
||||
|
||||
it "tests validity", ->
|
||||
scope.details =
|
||||
path:
|
||||
$dirty: true
|
||||
$invalid: true
|
||||
expect(scope.fieldValid('path')).toEqual false
|
||||
|
||||
it "returns errors by path", ->
|
||||
scope.details =
|
||||
path:
|
||||
$error:
|
||||
email: true
|
||||
required: true
|
||||
expect(scope.fieldErrors('path')).toEqual ["must be email address", "must not be blank"].join ", "
|
||||
@@ -7,6 +7,7 @@ describe "CheckoutCtrl", ->
|
||||
module("Darkswarm")
|
||||
order = {
|
||||
submit: ->
|
||||
navigate: ->
|
||||
}
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope.$new()
|
||||
@@ -22,23 +23,3 @@ describe "CheckoutCtrl", ->
|
||||
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 ", "
|
||||
|
||||
Reference in New Issue
Block a user