@@ -1943,26 +1943,6 @@ describe('directive',function(){
1943
1943
]
1944
1944
}
1945
1945
} ,
1946
- {
1947
- name : 'radios inline' ,
1948
- property : {
1949
- type : 'boolean' ,
1950
- } ,
1951
- form : {
1952
- key : [ "field" ] ,
1953
- type : "radios-inline" ,
1954
- titleMap : [
1955
- {
1956
- "value" : false ,
1957
- "name" : "No way"
1958
- } ,
1959
- {
1960
- "value" : true ,
1961
- "name" : "OK"
1962
- }
1963
- ]
1964
- }
1965
- } ,
1966
1946
{
1967
1947
name : 'select' ,
1968
1948
property : {
@@ -2115,7 +2095,7 @@ describe('directive',function(){
2115
2095
]
2116
2096
}
2117
2097
} ;
2118
-
2098
+
2119
2099
inject ( function ( $compile , $rootScope ) {
2120
2100
var scope = $rootScope . $new ( ) ;
2121
2101
scope . model = {
@@ -2143,6 +2123,103 @@ describe('directive',function(){
2143
2123
} ) ;
2144
2124
} ) ;
2145
2125
2126
+ it ( 'should not add "has-success" class to radios-inline field if a correct value is entered, but disableSuccessState is set on form' , function ( ) {
2127
+
2128
+ var field = {
2129
+ name : 'radios' ,
2130
+ property : {
2131
+ type : 'boolean' ,
2132
+ } ,
2133
+ form : {
2134
+ key : [ "field" ] ,
2135
+ type : "radios" ,
2136
+ titleMap : [
2137
+ {
2138
+ "value" : false ,
2139
+ "name" : "No way"
2140
+ } ,
2141
+ {
2142
+ "value" : true ,
2143
+ "name" : "OK"
2144
+ }
2145
+ ]
2146
+ }
2147
+ } ;
2148
+
2149
+ inject ( function ( $compile , $rootScope ) {
2150
+ var scope = $rootScope . $new ( ) ;
2151
+ scope . model = { }
2152
+ scope . schema = {
2153
+ type : 'object' ,
2154
+ properties : {
2155
+ field : field . property
2156
+ }
2157
+ } ;
2158
+ scope . form = [ field . form ] ;
2159
+
2160
+ var tmpl = angular . element ( '<form name="theForm" sf-schema="schema" sf-form="form" sf-model="model"></form>' ) ;
2161
+ $compile ( tmpl ) ( scope ) ;
2162
+ $rootScope . $apply ( ) ;
2163
+ var ngModelCtrl = tmpl . children ( ) . eq ( 0 ) . children ( ) . eq ( 0 ) . scope ( ) . ngModel ;
2164
+ ngModelCtrl . $valid = true ;
2165
+ ngModelCtrl . $pristine = false ;
2166
+ $rootScope . $apply ( ) ;
2167
+ tmpl . children ( ) . eq ( 0 ) . children ( ) . eq ( 0 ) . hasClass ( 'has-success' ) . should . be . true ;
2168
+ scope . form [ 0 ] . disableSuccessState = true ;
2169
+ $rootScope . $apply ( ) ;
2170
+ tmpl . children ( ) . eq ( 0 ) . children ( ) . eq ( 0 ) . hasClass ( 'has-success' ) . should . be . false ;
2171
+ } ) ;
2172
+ } ) ;
2173
+
2174
+ it ( 'should not add "has-error" class to radios-inline field if invalid value is entered, but disableErrorState is set on form' , function ( ) {
2175
+
2176
+ var field = {
2177
+ name : 'radios' ,
2178
+ property : {
2179
+ type : 'boolean' ,
2180
+ } ,
2181
+ form : {
2182
+ key : [ "field" ] ,
2183
+ type : "radios" ,
2184
+ titleMap : [
2185
+ {
2186
+ "value" : false ,
2187
+ "name" : "No way"
2188
+ } ,
2189
+ {
2190
+ "value" : true ,
2191
+ "name" : "OK"
2192
+ }
2193
+ ]
2194
+ }
2195
+ } ;
2196
+
2197
+ inject ( function ( $compile , $rootScope ) {
2198
+ var scope = $rootScope . $new ( ) ;
2199
+ scope . model = {
2200
+ field : field . errorValue
2201
+ }
2202
+ scope . schema = {
2203
+ type : 'object' ,
2204
+ properties : {
2205
+ field : field . property
2206
+ }
2207
+ } ;
2208
+ scope . form = [ field . form ] ;
2209
+
2210
+ var tmpl = angular . element ( '<form name="theForm" sf-schema="schema" sf-form="form" sf-model="model"></form>' ) ;
2211
+ $compile ( tmpl ) ( scope ) ;
2212
+ $rootScope . $apply ( ) ;
2213
+ var ngModelCtrl = tmpl . children ( ) . eq ( 0 ) . children ( ) . eq ( 0 ) . scope ( ) . ngModel ;
2214
+ ngModelCtrl . $invalid = true ;
2215
+ ngModelCtrl . $pristine = false ;
2216
+ $rootScope . $apply ( ) ;
2217
+ tmpl . children ( ) . eq ( 0 ) . children ( ) . eq ( 0 ) . hasClass ( 'has-error' ) . should . be . true ;
2218
+ scope . form [ 0 ] . disableErrorState = true ;
2219
+ $rootScope . $apply ( ) ;
2220
+ tmpl . children ( ) . eq ( 0 ) . children ( ) . eq ( 0 ) . hasClass ( 'has-error' ) . should . be . false ;
2221
+ } ) ;
2222
+ } ) ;
2146
2223
2147
2224
2148
2225
0 commit comments