spec/joosy/extensions/form/form_spec.coffee in joosy-1.2.0.alpha.58 vs spec/joosy/extensions/form/form_spec.coffee in joosy-1.2.0.alpha.59
- old
+ new
@@ -239,10 +239,14 @@
it "should fill class for invalidated fields by default", ->
@target.respond 422, 'Content-Type': 'application/json', '{"foo": "error!"}'
expect($(@nudeForm.$fields()[0]).attr 'class').toEqual 'field_with_errors'
+ it "should fill class for invalidated fields by default", ->
+ @target.respond 422, 'Content-Type': 'application/json', '{"errors":{"foo": "error!"}}'
+ expect($(@nudeForm.$fields()[0]).attr 'class').toEqual 'field_with_errors'
+
it "should trigger 'error' and complete default action if it returned true", ->
@nudeForm.error = sinon.spy ->
true
@target.respond 422, 'Content-Type': 'application/json', '{"foo": "error!"}'
expect($(@nudeForm.$fields()[0]).attr 'class').toEqual 'field_with_errors'
@@ -310,10 +314,10 @@
errors = {zombie: ['suck'], puppies: ['rock']}
result = @nudeForm.__stringifyErrors(errors)
expect(result).toEqual { "test[zombie]": ['suck'], "test[puppies]": ['rock'] }
- it "should prepare complexe response", ->
+ it "should prepare complex response", ->
@nudeForm.fill @resource
errors = {fluffies: {zombie: {mumbas: ['ololo']}}}
result = @nudeForm.__stringifyErrors(errors)
expect(result).toEqual { "fluffies[zombie][mumbas]": ['ololo'] }