@@ -104,49 +104,55 @@ describe('mdListItem directive', function() {
104
104
105
105
it ( 'creates buttons when used with ng-click' , function ( ) {
106
106
var listItem = setup ( '<md-list-item ng-click="sayHello()" ng-disabled="true"><p>Hello world</p></md-list-item>' ) ;
107
- var firstChild = listItem . children ( ) [ 0 ] ;
108
- expect ( firstChild . nodeName ) . toBe ( 'MD-BUTTON' ) ;
109
- expect ( firstChild . hasAttribute ( 'ng-disabled' ) ) . toBeTruthy ( ) ;
110
- expect ( firstChild . childNodes [ 0 ] . nodeName ) . toBe ( 'DIV' ) ;
111
- expect ( firstChild . childNodes [ 0 ] . childNodes [ 0 ] . nodeName ) . toBe ( 'P' ) ;
107
+ var buttonChild = listItem . children ( ) . children ( ) [ 0 ] ;
108
+ var innerChild = listItem . children ( ) . children ( ) [ 1 ] ;
109
+ expect ( buttonChild . nodeName ) . toBe ( 'MD-BUTTON' ) ;
110
+ expect ( buttonChild . hasAttribute ( 'ng-disabled' ) ) . toBeTruthy ( ) ;
111
+ expect ( innerChild . nodeName ) . toBe ( 'DIV' ) ;
112
+ expect ( innerChild . childNodes [ 0 ] . nodeName ) . toBe ( 'P' ) ;
112
113
} ) ;
113
114
114
115
it ( 'creates buttons when used with ui-sref' , function ( ) {
115
116
var listItem = setup ( '<md-list-item ui-sref="somestate"><p>Hello world</p></md-list-item>' ) ;
116
- var firstChild = listItem . children ( ) [ 0 ] ;
117
+ var firstChild = listItem . children ( ) . children ( ) [ 0 ] ;
117
118
expect ( firstChild . nodeName ) . toBe ( 'MD-BUTTON' ) ;
118
119
expect ( firstChild . hasAttribute ( 'ui-sref' ) ) . toBeTruthy ( ) ;
119
120
} ) ;
120
121
121
122
it ( 'creates buttons when used with href' , function ( ) {
122
123
var listItem = setup ( '<md-list-item href="/somewhere"><p>Hello world</p></md-list-item>' ) ;
123
- var firstChild = listItem . children ( ) [ 0 ] ;
124
+ var firstChild = listItem . children ( ) . children ( ) [ 0 ] ;
124
125
expect ( firstChild . nodeName ) . toBe ( 'MD-BUTTON' ) ;
125
126
expect ( firstChild . hasAttribute ( 'href' ) ) . toBeTruthy ( ) ;
126
127
} ) ;
127
128
128
129
it ( 'moves aria-label to primary action' , function ( ) {
129
130
var listItem = setup ( '<md-list-item ng-click="sayHello()" aria-label="Hello"></md-list-item>' ) ;
130
131
var listItemChildren = listItem . children ( ) ;
131
- expect ( listItemChildren [ 0 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
132
- expect ( listItemChildren . attr ( 'aria-label' ) ) . toBe ( 'Hello' ) ;
132
+ expect ( listItemChildren [ 0 ] . nodeName ) . toBe ( 'DIV' ) ;
133
+ expect ( listItemChildren ) . toHaveClass ( 'md-button' ) ;
134
+ expect ( listItemChildren . children ( ) [ 0 ] . getAttribute ( 'aria-label' ) ) . toBe ( 'Hello' ) ;
133
135
} ) ;
134
136
135
137
it ( 'moves md-secondary items outside of the button' , function ( ) {
136
138
var listItem = setup ( '<md-list-item ng-click="sayHello()"><p>Hello World</p><md-icon class="md-secondary" ng-click="goWild()"></md-icon></md-list-item>' ) ;
139
+ // First child is our button and content holder
137
140
var firstChild = listItem . children ( ) . eq ( 0 ) ;
138
- expect ( firstChild [ 0 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
139
- expect ( firstChild . children ( ) . length ) . toBe ( 1 ) ;
141
+ expect ( firstChild [ 0 ] . nodeName ) . toBe ( 'DIV' ) ;
142
+ // It should contain two elements, the button overlay and the actual content
143
+ expect ( firstChild . children ( ) . length ) . toBe ( 2 ) ;
140
144
var secondChild = listItem . children ( ) . eq ( 1 ) ;
141
145
expect ( secondChild [ 0 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
142
146
expect ( secondChild . hasClass ( 'md-secondary-container' ) ) . toBeTruthy ( ) ;
143
147
} ) ;
144
148
145
149
it ( 'moves multiple md-secondary items outside of the button' , function ( ) {
146
150
var listItem = setup ( '<md-list-item ng-click="sayHello()"><p>Hello World</p><md-icon class="md-secondary" ng-click="goWild()"><md-icon class="md-secondary" ng-click="goWild2()"></md-icon></md-list-item>' ) ;
151
+ // First child is our button and content holder
147
152
var firstChild = listItem . children ( ) . eq ( 0 ) ;
148
- expect ( firstChild [ 0 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
149
- expect ( firstChild . children ( ) . length ) . toBe ( 1 ) ;
153
+ expect ( firstChild [ 0 ] . nodeName ) . toBe ( 'DIV' ) ;
154
+ // It should contain two elements, the button overlay and the actual content
155
+ expect ( firstChild . children ( ) . length ) . toBe ( 2 ) ;
150
156
var secondChild = listItem . children ( ) . eq ( 1 ) ;
151
157
expect ( secondChild [ 0 ] . nodeName ) . toBe ( 'DIV' ) ;
152
158
expect ( secondChild . hasClass ( 'md-secondary-container' ) ) . toBeTruthy ( ) ;
0 commit comments