@@ -3,7 +3,7 @@ describe('mdListItem directive', function() {
3
3
var $compile , $rootScope ;
4
4
5
5
beforeEach ( module ( 'material.components.list' , 'material.components.checkbox' , 'material.components.switch' ) ) ;
6
- beforeEach ( inject ( function ( _$compile_ , _$rootScope_ ) {
6
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ ) {
7
7
$compile = _$compile_ ;
8
8
$rootScope = _$rootScope_ ;
9
9
} ) ) ;
@@ -26,16 +26,16 @@ describe('mdListItem directive', function() {
26
26
return el ;
27
27
}
28
28
29
- it ( 'supports empty list items' , function ( ) {
29
+ it ( 'supports empty list items' , function ( ) {
30
30
var list = setup ( '\
31
31
<md-list>\
32
32
<md-list-item></md-list-item>\
33
33
</md-list>'
34
- ) ;
34
+ ) ;
35
35
36
36
var cntr = list [ 0 ] . querySelector ( 'div' ) ;
37
37
38
- if ( cntr && cntr . click ) {
38
+ if ( cntr && cntr . click ) {
39
39
cntr . click ( ) ;
40
40
expect ( $rootScope . modelVal ) . toBe ( false ) ;
41
41
}
@@ -46,7 +46,7 @@ describe('mdListItem directive', function() {
46
46
var listItem = setup ( '<md-list-item><md-checkbox ng-model="modelVal"></md-checkbox></md-list-item>' ) ;
47
47
var cntr = listItem [ 0 ] . querySelector ( 'div' ) ;
48
48
49
- if ( cntr && cntr . click ) {
49
+ if ( cntr && cntr . click ) {
50
50
cntr . click ( ) ;
51
51
expect ( $rootScope . modelVal ) . toBe ( true ) ;
52
52
}
@@ -57,48 +57,48 @@ describe('mdListItem directive', function() {
57
57
var listItem = setup ( '<md-list-item><md-switch ng-model="modelVal"></md-switch></md-list-item>' ) ;
58
58
var cntr = listItem [ 0 ] . querySelector ( 'div' ) ;
59
59
60
- if ( cntr && cntr . click ) {
60
+ if ( cntr && cntr . click ) {
61
61
cntr . click ( ) ;
62
62
expect ( $rootScope . modelVal ) . toBe ( true ) ;
63
63
}
64
64
65
65
} ) ;
66
66
67
67
it ( 'should convert spacebar keypress events as clicks' , inject ( function ( $mdConstant ) {
68
- var listItem = setup ( '<md-list-item><md-checkbox ng-model="modelVal"></md-checkbox></md-list-item>' ) ;
69
- var checkbox = angular . element ( listItem [ 0 ] . querySelector ( 'md-checkbox' ) ) ;
70
-
71
- expect ( $rootScope . modelVal ) . toBeFalsy ( ) ;
72
- checkbox . triggerHandler ( {
73
- type : 'keypress' ,
74
- keyCode : $mdConstant . KEY_CODE . SPACE
75
- } ) ;
76
- expect ( $rootScope . modelVal ) . toBe ( true ) ;
68
+ var listItem = setup ( '<md-list-item><md-checkbox ng-model="modelVal"></md-checkbox></md-list-item>' ) ;
69
+ var checkbox = angular . element ( listItem [ 0 ] . querySelector ( 'md-checkbox' ) ) ;
70
+
71
+ expect ( $rootScope . modelVal ) . toBeFalsy ( ) ;
72
+ checkbox . triggerHandler ( {
73
+ type : 'keypress' ,
74
+ keyCode : $mdConstant . KEY_CODE . SPACE
75
+ } ) ;
76
+ expect ( $rootScope . modelVal ) . toBe ( true ) ;
77
77
} ) ) ;
78
78
79
79
it ( 'should not convert spacebar keypress for text areas' , inject ( function ( $mdConstant ) {
80
- var listItem = setup ( '<md-list-item><textarea ng-model="modelVal"></md-list-item>' ) ;
81
- var inputEl = angular . element ( listItem [ 0 ] . querySelector ( 'textarea' ) [ 0 ] ) ;
82
-
83
- expect ( $rootScope . modelVal ) . toBeFalsy ( ) ;
84
- inputEl . triggerHandler ( {
85
- type : 'keypress' ,
86
- keyCode : $mdConstant . KEY_CODE . SPACE
87
- } ) ;
88
- expect ( $rootScope . modelVal ) . toBeFalsy ( ) ;
80
+ var listItem = setup ( '<md-list-item><textarea ng-model="modelVal"></md-list-item>' ) ;
81
+ var inputEl = angular . element ( listItem [ 0 ] . querySelector ( 'textarea' ) [ 0 ] ) ;
82
+
83
+ expect ( $rootScope . modelVal ) . toBeFalsy ( ) ;
84
+ inputEl . triggerHandler ( {
85
+ type : 'keypress' ,
86
+ keyCode : $mdConstant . KEY_CODE . SPACE
87
+ } ) ;
88
+ expect ( $rootScope . modelVal ) . toBeFalsy ( ) ;
89
89
} ) ) ;
90
90
91
91
xit ( 'should not convert spacebar keypress for text inputs' , inject ( function ( $mdConstant ) {
92
92
93
- var listItem = setup ( '<md-list-item><input ng-keypress="pressed = true" type="text"></md-list-item>' ) ;
94
- var inputEl = angular . element ( listItem [ 0 ] . querySelector ( 'input' ) [ 0 ] ) ;
93
+ var listItem = setup ( '<md-list-item><input ng-keypress="pressed = true" type="text"></md-list-item>' ) ;
94
+ var inputEl = angular . element ( listItem [ 0 ] . querySelector ( 'input' ) [ 0 ] ) ;
95
95
96
- expect ( $rootScope . pressed ) . toBeFalsy ( ) ;
97
- inputEl . triggerHandler ( {
98
- type : 'keypress' ,
99
- keyCode : $mdConstant . KEY_CODE . SPACE
100
- } ) ;
101
- expect ( $rootScope . pressed ) . toBe ( true ) ;
96
+ expect ( $rootScope . pressed ) . toBeFalsy ( ) ;
97
+ inputEl . triggerHandler ( {
98
+ type : 'keypress' ,
99
+ keyCode : $mdConstant . KEY_CODE . SPACE
100
+ } ) ;
101
+ expect ( $rootScope . pressed ) . toBe ( true ) ;
102
102
} ) ) ;
103
103
104
104
@@ -157,6 +157,21 @@ describe('mdListItem directive', function() {
157
157
expect ( listItem . hasClass ( 'md-no-proxy' ) ) . toBeTruthy ( ) ;
158
158
} ) ;
159
159
160
+ it ( 'should copy md-icon.md-secondary attributes to the button' , function ( ) {
161
+ var listItem = setup (
162
+ '<md-list-item>' +
163
+ ' <div>Content Here</div>' +
164
+ ' <md-checkbox></md-checkbox>' +
165
+ ' <md-icon class="md-secondary" ng-click="sayHello()" ng-disabled="true">Hello</md-icon>' +
166
+ '</md-list-item>'
167
+ ) ;
168
+
169
+ var button = listItem . find ( 'md-button' ) ;
170
+
171
+ expect ( button [ 0 ] . hasAttribute ( 'ng-click' ) ) . toBeTruthy ( ) ;
172
+ expect ( button [ 0 ] . hasAttribute ( 'ng-disabled' ) ) . toBeTruthy ( ) ;
173
+ } ) ;
174
+
160
175
describe ( 'with a clickable item' , function ( ) {
161
176
162
177
it ( 'should wrap secondary icons in a md-button' , function ( ) {
0 commit comments