@@ -17,6 +17,15 @@ module('Integration | Component | bs form element', function(hooks) {
17
17
]
18
18
} ;
19
19
20
+ const nestedValidation = {
21
+ nested : {
22
+ name : [
23
+ validatePresence ( true ) ,
24
+ validateLength ( { min : 4 } )
25
+ ]
26
+ }
27
+ } ;
28
+
20
29
test ( 'form is submitted if valid and validation success shown' , async function ( assert ) {
21
30
let model = {
22
31
name : '1234' ,
@@ -66,6 +75,31 @@ module('Integration | Component | bs form element', function(hooks) {
66
75
assert . verifySteps ( [ 'Invalid action has been called.' ] ) ;
67
76
} ) ;
68
77
78
+ test ( 'validation nested errors are shown on submit' , async function ( assert ) {
79
+ let model = {
80
+ nested : { name : '' }
81
+ } ;
82
+
83
+ this . set ( 'model' , model ) ;
84
+ this . set ( 'validation' , nestedValidation ) ;
85
+ this . submitAction = function ( ) {
86
+ assert . ok ( false , 'submit action must not been called.' ) ;
87
+ } ;
88
+ this . invalidAction = function ( ) {
89
+ assert . step ( 'Invalid action has been called.' ) ;
90
+ } ;
91
+
92
+ await render ( hbs `
93
+ <BsForm @model={{changeset this.model this.validation}} @onSubmit={{this.submitAction}} @onInvalid={{this.invalidAction}} as |form|>
94
+ <form.element @label="Name" @property="nested.name" />
95
+ </BsForm>
96
+ ` ) ;
97
+
98
+ await triggerEvent ( 'form' , 'submit' ) ;
99
+ assert . dom ( 'input' ) . hasClass ( 'is-invalid' , 'input has error class' ) ;
100
+ assert . verifySteps ( [ 'Invalid action has been called.' ] ) ;
101
+ } ) ;
102
+
69
103
test ( 'validation errors are shown after blur' , async function ( assert ) {
70
104
this . set ( 'model' , { name : '' } ) ;
71
105
this . set ( 'validation' , validation ) ;
0 commit comments