@@ -17,15 +17,15 @@ describe('<md-select>', function() {
17
17
backdrops . remove ( ) ;
18
18
} ) ) ;
19
19
20
- it ( 'should preserve tabindex' , inject ( function ( $document ) {
20
+ it ( 'should preserve tabindex' , function ( ) {
21
21
var select = setupSelect ( 'tabindex="2", ng-model="val"' ) . find ( 'md-select' ) ;
22
22
expect ( select . attr ( 'tabindex' ) ) . toBe ( '2' ) ;
23
- } ) ) ;
23
+ } ) ;
24
24
25
- it ( 'supports non-disabled state' , inject ( function ( $document ) {
25
+ it ( 'supports non-disabled state' , function ( ) {
26
26
var select = setupSelect ( 'ng-model="val"' ) . find ( 'md-select' ) ;
27
27
expect ( select . attr ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
28
- } ) ) ;
28
+ } ) ;
29
29
30
30
it ( 'supports disabled state' , inject ( function ( $document ) {
31
31
var select = setupSelect ( 'disabled="disabled", ng-model="val"' ) . find ( 'md-select' ) ;
@@ -34,7 +34,7 @@ describe('<md-select>', function() {
34
34
expect ( select . attr ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
35
35
} ) ) ;
36
36
37
- it ( 'supports passing classes to the container' , inject ( function ( $document , $timeout ) {
37
+ it ( 'supports passing classes to the container' , inject ( function ( $document ) {
38
38
var select = setupSelect ( 'ng-model="val", md-container-class="test"' ) . find ( 'md-select' ) ;
39
39
openSelect ( select ) ;
40
40
@@ -142,7 +142,7 @@ describe('<md-select>', function() {
142
142
143
143
openSelect ( select ) ;
144
144
145
- var opt = $document . find ( 'md-option' ) [ 0 ] . click ( ) ;
145
+ $document . find ( 'md-option' ) [ 0 ] . click ( ) ;
146
146
147
147
waitForSelectClose ( ) ;
148
148
@@ -158,17 +158,17 @@ describe('<md-select>', function() {
158
158
expect ( el ) . not . toHaveClass ( 'md-input-has-value' ) ;
159
159
} ) ) ;
160
160
161
- it ( 'should match label to given input id' , inject ( function ( $rootScope ) {
161
+ it ( 'should match label to given input id' , function ( ) {
162
162
var el = setupSelect ( 'ng-model="$root.value", id="foo"' ) ;
163
163
expect ( el . find ( 'label' ) . attr ( 'for' ) ) . toBe ( 'foo' ) ;
164
164
expect ( el . find ( 'md-select' ) . attr ( 'id' ) ) . toBe ( 'foo' ) ;
165
- } ) ) ;
165
+ } ) ;
166
166
167
- it ( 'should match label to automatic input id' , inject ( function ( $rootScope ) {
167
+ it ( 'should match label to automatic input id' , function ( ) {
168
168
var el = setupSelect ( 'ng-model="$root.value"' ) ;
169
169
expect ( el . find ( 'md-select' ) . attr ( 'id' ) ) . toBeTruthy ( ) ;
170
170
expect ( el . find ( 'label' ) . attr ( 'for' ) ) . toBe ( el . find ( 'md-select' ) . attr ( 'id' ) ) ;
171
- } ) ) ;
171
+ } ) ;
172
172
} ) ;
173
173
174
174
describe ( 'label behavior' , function ( ) {
@@ -212,6 +212,29 @@ describe('<md-select>', function() {
212
212
expect ( label . text ( ) ) . toBe ( 'One, Three' ) ;
213
213
expect ( label . hasClass ( 'md-select-placeholder' ) ) . toBe ( false ) ;
214
214
} ) ) ;
215
+
216
+ it ( 'supports raw html' , inject ( function ( $rootScope , $compile , $sce ) {
217
+ $rootScope . val = 0 ;
218
+ $rootScope . opts = [
219
+ { id : 0 , label : '<p>Hello World</p>' } ,
220
+ { id : 1 , label : 'Hello World' }
221
+ ] ;
222
+ angular . forEach ( $rootScope . opts , function ( opt ) {
223
+ opt . label = $sce . trustAs ( 'html' , opt . label ) ;
224
+ } ) ;
225
+ var select = $compile ( '<md-input-container>' +
226
+ '<label>Placeholder</label>' +
227
+ '<md-select ng-model="val" placeholder="Placeholder">' +
228
+ '<md-option ng-value="opt.id" ng-repeat="opt in opts" ng-bind-html="opt.label"></md-option>' +
229
+ '</md-select>' +
230
+ '</md-input-container>' ) ( $rootScope ) . find ( 'md-select' ) ;
231
+ var label = select . find ( 'md-select-value' ) . children ( ) . eq ( 0 ) ;
232
+ $rootScope . $digest ( ) ;
233
+
234
+
235
+ expect ( label . text ( ) ) . toBe ( 'Hello World' ) ;
236
+ expect ( label . html ( ) ) . toBe ( '<p>Hello World</p>' ) ;
237
+ } ) ) ;
215
238
} ) ;
216
239
217
240
it ( 'auto-infers a value when none specified' , inject ( function ( $rootScope ) {
@@ -221,7 +244,7 @@ describe('<md-select>', function() {
221
244
expect ( selectedOptions ( el ) . length ) . toBe ( 1 ) ;
222
245
} ) ) ;
223
246
224
- it ( 'errors for duplicate md-options, non-dynamic value' , inject ( function ( $rootScope ) {
247
+ it ( 'errors for duplicate md-options, non-dynamic value' , inject ( function ( ) {
225
248
expect ( function ( ) {
226
249
setup ( 'ng-model="$root.model"' , '<md-option value="a">Hello</md-option>' +
227
250
'<md-option value="a">Goodbye</md-option>' ) ;
@@ -582,7 +605,7 @@ describe('<md-select>', function() {
582
605
it ( 'does not let an empty array satisfy required' , inject ( function ( $rootScope , $compile ) {
583
606
$rootScope . model = [ ] ;
584
607
$rootScope . opts = [ 1 , 2 , 3 , 4 ] ;
585
- var form = $compile ( '<form name="testForm">' +
608
+ $compile ( '<form name="testForm">' +
586
609
'<md-select ng-model="model", name="multiSelect" required="required" multiple="multiple">' +
587
610
'<md-option ng-repeat="opt in opts" ng-value="opt"></md-option>' +
588
611
'</md-select></form>' ) ( $rootScope ) ;
@@ -689,25 +712,24 @@ describe('<md-select>', function() {
689
712
expect ( select . attr ( 'aria-label' ) ) . toBe ( 'Pick' ) ;
690
713
} ) ) ;
691
714
692
- it ( 'preserves existing aria-label' , inject ( function ( $rootScope ) {
715
+ it ( 'preserves existing aria-label' , function ( ) {
693
716
var select = setupSelect ( 'ng-model="someVal", aria-label="Hello world", placeholder="Pick"' ) . find ( 'md-select' ) ;
694
717
expect ( select . attr ( 'aria-label' ) ) . toBe ( 'Hello world' ) ;
695
- } ) ) ;
718
+ } ) ;
696
719
697
720
it ( 'should expect an aria-label if none is present' , inject ( function ( $compile , $rootScope , $log ) {
698
721
spyOn ( $log , 'warn' ) ;
699
- var select = setupSelect ( 'ng-model="someVal"' , null , true ) . find ( 'md-select' ) ;
722
+ setupSelect ( 'ng-model="someVal"' , null , true ) . find ( 'md-select' ) ;
700
723
$rootScope . $apply ( ) ;
701
724
expect ( $log . warn ) . toHaveBeenCalled ( ) ;
702
725
703
726
$log . warn . calls . reset ( ) ;
704
- select = setupSelect ( 'ng-model="someVal", aria-label="Hello world"' ) . find ( 'md-select' ) ;
727
+ setupSelect ( 'ng-model="someVal", aria-label="Hello world"' ) . find ( 'md-select' ) ;
705
728
$rootScope . $apply ( ) ;
706
729
expect ( $log . warn ) . not . toHaveBeenCalled ( ) ;
707
730
} ) ) ;
708
731
709
- it ( 'sets up the aria-expanded attribute' , inject ( function ( $document , $timeout ) {
710
- disableAnimations ( ) ;
732
+ it ( 'sets up the aria-expanded attribute' , inject ( function ( $document ) {
711
733
712
734
expect ( el . attr ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
713
735
openSelect ( el ) ;
@@ -725,7 +747,7 @@ describe('<md-select>', function() {
725
747
726
748
expect ( el . attr ( 'aria-multiselectable' ) ) . toBe ( 'true' ) ;
727
749
} ) ) ;
728
- it ( 'sets up the aria-selected attribute' , inject ( function ( $rootScope ) {
750
+ it ( 'sets up the aria-selected attribute' , function ( ) {
729
751
var el = setup ( 'ng-model="$root.model"' , [ 1 , 2 , 3 ] ) ;
730
752
var options = el . find ( 'md-option' ) ;
731
753
expect ( options . eq ( 2 ) . attr ( 'aria-selected' ) ) . toBe ( 'false' ) ;
@@ -734,7 +756,7 @@ describe('<md-select>', function() {
734
756
target : el . find ( 'md-option' ) [ 2 ]
735
757
} ) ;
736
758
expect ( options . eq ( 2 ) . attr ( 'aria-selected' ) ) . toBe ( 'true' ) ;
737
- } ) ) ;
759
+ } ) ;
738
760
} ) ;
739
761
740
762
describe ( 'keyboard controls' , function ( ) {
@@ -786,9 +808,7 @@ describe('<md-select>', function() {
786
808
} ) ;
787
809
788
810
describe ( 'md-select-menu' , function ( ) {
789
- it ( 'can be closed with escape' , inject ( function ( $document , $rootScope , $animate ) {
790
- disableAnimations ( ) ;
791
-
811
+ it ( 'can be closed with escape' , inject ( function ( $document ) {
792
812
var el = setupSelect ( 'ng-model="someVal"' , [ 1 , 2 , 3 ] ) . find ( 'md-select' ) ;
793
813
openSelect ( el ) ;
794
814
var selectMenu = angular . element ( $document . find ( 'md-select-menu' ) ) ;
0 commit comments