@@ -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_ ;
@@ -136,6 +140,41 @@ describe('$aria', function() {
136
140
} ) ;
137
141
} ) ;
138
142
143
+ describe ( 'roles for custom inputs' , function ( ) {
144
+ beforeEach ( injectScopeAndCompiler ) ;
145
+
146
+ it ( 'should add missing role="checkbox" to custom input' , function ( ) {
147
+ scope . $apply ( 'val = true' ) ;
148
+ compileInput ( '<div type="checkbox" ng-model="val"></div>' ) ;
149
+ expect ( element . attr ( 'role' ) ) . toBe ( 'checkbox' ) ;
150
+ } ) ;
151
+ it ( 'should not add a role to a native checkbox' , function ( ) {
152
+ scope . $apply ( 'val = true' ) ;
153
+ compileInput ( '<input type="checkbox" ng-model="val"></div>' ) ;
154
+ expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
155
+ } ) ;
156
+ it ( 'should add missing role="radio" to custom input' , function ( ) {
157
+ scope . $apply ( 'val = true' ) ;
158
+ compileInput ( '<div type="radio" ng-model="val"></div>' ) ;
159
+ expect ( element . attr ( 'role' ) ) . toBe ( 'radio' ) ;
160
+ } ) ;
161
+ it ( 'should not add a role to a native radio button' , function ( ) {
162
+ scope . $apply ( 'val = true' ) ;
163
+ compileInput ( '<input type="radio" ng-model="val"></div>' ) ;
164
+ expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
165
+ } ) ;
166
+ it ( 'should add missing role="slider" to custom input' , function ( ) {
167
+ scope . $apply ( 'val = true' ) ;
168
+ compileInput ( '<div type="range" ng-model="val"></div>' ) ;
169
+ expect ( element . attr ( 'role' ) ) . toBe ( 'slider' ) ;
170
+ } ) ;
171
+ it ( 'should not add a role to a native range input' , function ( ) {
172
+ scope . $apply ( 'val = true' ) ;
173
+ compileInput ( '<input type="range" ng-model="val"></div>' ) ;
174
+ expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
175
+ } ) ;
176
+ } ) ;
177
+
139
178
describe ( 'aria-checked when disabled' , function ( ) {
140
179
beforeEach ( configAriaProvider ( {
141
180
ariaChecked : false
0 commit comments