@@ -85,6 +85,28 @@ describe('$aria', function() {
8585 expect ( element . attr ( 'aria-checked' ) ) . toBe ( 'false' ) ;
8686 } ) ;
8787
88+ it ( 'should handle checkbox with string model values using ng(True|False)Value' , function ( ) {
89+ var element = $compile ( '<input type="checkbox" ng-model="val" ng-true-value="\'yes\'" ' +
90+ 'ng-false-value="\'no\'">'
91+ ) ( scope ) ;
92+
93+ scope . $apply ( 'val="yes"' ) ;
94+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
95+
96+ scope . $apply ( 'val="no"' ) ;
97+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'false' ) ;
98+ } ) ;
99+
100+ it ( 'should handle checkbox with integer model values using ngTrueValue' , function ( ) {
101+ var element = $compile ( '<input type="checkbox" ng-model="val" ng-true-value="0">' ) ( scope ) ;
102+
103+ scope . $apply ( 'val=0' ) ;
104+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
105+
106+ scope . $apply ( 'val=1' ) ;
107+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'false' ) ;
108+ } ) ;
109+
88110 it ( 'should attach itself to input type="radio"' , function ( ) {
89111 var element = $compile ( '<input type="radio" ng-model="val" value="one">' +
90112 '<input type="radio" ng-model="val" value="two">' ) ( scope ) ;
@@ -98,6 +120,36 @@ describe('$aria', function() {
98120 expect ( element . eq ( 1 ) . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
99121 } ) ;
100122
123+ it ( 'should handle radios with integer model values' , function ( ) {
124+ var element = $compile ( '<input type="radio" ng-model="val" value="0">' +
125+ '<input type="radio" ng-model="val" value="1">' ) ( scope ) ;
126+
127+ scope . $apply ( 'val=0' ) ;
128+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
129+ expect ( element . eq ( 1 ) . attr ( 'aria-checked' ) ) . toBe ( 'false' ) ;
130+
131+ scope . $apply ( 'val=1' ) ;
132+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'false' ) ;
133+ expect ( element . eq ( 1 ) . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
134+ } ) ;
135+
136+ it ( 'should handle radios with boolean model values using ngValue' , function ( ) {
137+ var element = $compile ( '<input type="radio" ng-model="val" ng-value="valExp">' +
138+ '<input type="radio" ng-model="val" ng-value="valExp2">' ) ( scope ) ;
139+
140+ scope . $apply ( function ( ) {
141+ scope . valExp = true ;
142+ scope . valExp2 = false ;
143+ scope . val = true ;
144+ } ) ;
145+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
146+ expect ( element . eq ( 1 ) . attr ( 'aria-checked' ) ) . toBe ( 'false' ) ;
147+
148+ scope . $apply ( 'val = false' ) ;
149+ expect ( element . eq ( 0 ) . attr ( 'aria-checked' ) ) . toBe ( 'false' ) ;
150+ expect ( element . eq ( 1 ) . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
151+ } ) ;
152+
101153 it ( 'should attach itself to role="radio"' , function ( ) {
102154 scope . $apply ( "val = 'one'" ) ;
103155 compileInput ( '<div role="radio" ng-model="val" value="{{val}}"></div>' ) ;
0 commit comments