@@ -5,6 +5,10 @@ describe('$aria', function() {
5
5
6
6
beforeEach ( module ( 'ngAria' ) ) ;
7
7
8
+ afterEach ( function ( ) {
9
+ dealoc ( element ) ;
10
+ } ) ;
11
+
8
12
function injectScopeAndCompiler ( ) {
9
13
return inject ( function ( _$compile_ , _$rootScope_ ) {
10
14
$compile = _$compile_ ;
@@ -188,6 +192,41 @@ describe('$aria', function() {
188
192
} ) ;
189
193
} ) ;
190
194
195
+ describe ( 'roles for custom inputs' , function ( ) {
196
+ beforeEach ( injectScopeAndCompiler ) ;
197
+
198
+ it ( 'should add missing role="checkbox" to custom input' , function ( ) {
199
+ scope . $apply ( 'val = true' ) ;
200
+ compileInput ( '<div type="checkbox" ng-model="val"></div>' ) ;
201
+ expect ( element . attr ( 'role' ) ) . toBe ( 'checkbox' ) ;
202
+ } ) ;
203
+ it ( 'should not add a role to a native checkbox' , function ( ) {
204
+ scope . $apply ( 'val = true' ) ;
205
+ compileInput ( '<input type="checkbox" ng-model="val"></div>' ) ;
206
+ expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
207
+ } ) ;
208
+ it ( 'should add missing role="radio" to custom input' , function ( ) {
209
+ scope . $apply ( 'val = true' ) ;
210
+ compileInput ( '<div type="radio" ng-model="val"></div>' ) ;
211
+ expect ( element . attr ( 'role' ) ) . toBe ( 'radio' ) ;
212
+ } ) ;
213
+ it ( 'should not add a role to a native radio button' , function ( ) {
214
+ scope . $apply ( 'val = true' ) ;
215
+ compileInput ( '<input type="radio" ng-model="val"></div>' ) ;
216
+ expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
217
+ } ) ;
218
+ it ( 'should add missing role="slider" to custom input' , function ( ) {
219
+ scope . $apply ( 'val = true' ) ;
220
+ compileInput ( '<div type="range" ng-model="val"></div>' ) ;
221
+ expect ( element . attr ( 'role' ) ) . toBe ( 'slider' ) ;
222
+ } ) ;
223
+ it ( 'should not add a role to a native range input' , function ( ) {
224
+ scope . $apply ( 'val = true' ) ;
225
+ compileInput ( '<input type="range" ng-model="val"></div>' ) ;
226
+ expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
227
+ } ) ;
228
+ } ) ;
229
+
191
230
describe ( 'aria-checked when disabled' , function ( ) {
192
231
beforeEach ( configAriaProvider ( {
193
232
ariaChecked : false
0 commit comments