@@ -26,13 +26,13 @@ describe('material.components.menuBar', function() {
2626 } ) ;
2727
2828 describe ( 'ARIA' , function ( ) {
29-
29+
3030 it ( 'sets role="menubar" on the menubar' , function ( ) {
3131 var menuBar = setup ( ) ;
3232 var ariaRole = menuBar [ 0 ] . getAttribute ( 'role' ) ;
3333 expect ( ariaRole ) . toBe ( 'menubar' ) ;
3434 } ) ;
35-
35+
3636 it ( 'should set the role on the menu trigger correctly' , inject ( function ( $compile , $rootScope ) {
3737 var el = $compile (
3838 '<md-menu-bar>' +
@@ -235,7 +235,7 @@ describe('material.components.menuBar', function() {
235235 it ( 'clicks the focused menu' , function ( ) {
236236 var opened = false ;
237237 spyOn ( ctrl , 'getFocusedMenu' ) . and . returnValue ( {
238- querySelector : function ( ) { return true }
238+ querySelector : function ( ) { return true ; }
239239 } ) ;
240240 spyOn ( angular , 'element' ) . and . returnValue ( {
241241 controller : function ( ) { return {
@@ -317,13 +317,24 @@ describe('material.components.menuBar', function() {
317317
318318 describe ( 'md-menu-item directive' , function ( ) {
319319 describe ( 'type="checkbox"' , function ( ) {
320+ function setup ( attrs ) {
321+ return setupMenuItem ( attrs + ' type="checkbox"' ) ;
322+ }
323+
320324 it ( 'compiles' , function ( ) {
321325 var menuItem = setup ( 'ng-model="test"' ) [ 0 ] ;
322326 expect ( menuItem . classList . contains ( 'md-indent' ) ) . toBe ( true ) ;
323327 var children = menuItem . children ;
324328 expect ( children [ 0 ] . nodeName ) . toBe ( 'MD-ICON' ) ;
325329 expect ( children [ 1 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
326330 } ) ;
331+ it ( 'compiles with ng-repeat' , function ( ) {
332+ var menuItem = setup ( 'ng-repeat="i in [1, 2, 3]"' ) [ 0 ] ;
333+ expect ( menuItem . classList . contains ( 'md-indent' ) ) . toBe ( true ) ;
334+ var children = menuItem . children ;
335+ expect ( children [ 0 ] . nodeName ) . toBe ( 'MD-ICON' ) ;
336+ expect ( children [ 1 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
337+ } ) ;
327338 it ( 'sets aria role' , function ( ) {
328339 var menuItem = setup ( ) [ 0 ] . querySelector ( 'md-button' ) ;
329340 expect ( menuItem . getAttribute ( 'role' ) ) . toBe ( 'menuitemcheckbox' ) ;
@@ -354,36 +365,27 @@ describe('material.components.menuBar', function() {
354365 expect ( menuItem . children [ 0 ] . style . display ) . toBe ( '' ) ;
355366 expect ( button . getAttribute ( 'aria-checked' ) ) . toBe ( 'true' ) ;
356367 } ) ) ;
368+ } ) ;
357369
370+ describe ( 'type="radio"' , function ( ) {
358371 function setup ( attrs ) {
359- attrs = attrs || '' ;
360-
361- var template = '<md-menu-item type="checkbox" ' + attrs + '>Test Item</md-menu-item>' ;
362-
363- var checkboxMenuItem ;
364- inject ( function ( $compile , $rootScope ) {
365- // We need to have a `md-menu-bar` as a parent of our menu item, because the menu-item
366- // is only wrapping and indenting the content if it's inside of a menu bar.
367- var menuBarMock = angular . element ( '<md-menu-bar>' ) ;
368- var itemEl = angular . element ( template ) ;
369-
370- menuBarMock . append ( itemEl ) ;
371- checkboxMenuItem = $compile ( itemEl ) ( $rootScope ) ;
372-
373- $rootScope . $digest ( ) ;
374- } ) ;
375- return checkboxMenuItem ;
372+ return setupMenuItem ( attrs + ' type="radio"' ) ;
376373 }
377- } ) ;
378374
379- describe ( 'type="radio"' , function ( ) {
380375 it ( 'compiles' , function ( ) {
381376 var menuItem = setup ( 'ng-model="test"' ) [ 0 ] ;
382377 expect ( menuItem . classList . contains ( 'md-indent' ) ) . toBe ( true ) ;
383378 var children = menuItem . children ;
384379 expect ( children [ 0 ] . nodeName ) . toBe ( 'MD-ICON' ) ;
385380 expect ( children [ 1 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
386381 } ) ;
382+ it ( 'compiles with ng-repeat' , function ( ) {
383+ var menuItem = setup ( 'ng-repeat="i in [1, 2, 3]"' ) [ 0 ] ;
384+ expect ( menuItem . classList . contains ( 'md-indent' ) ) . toBe ( true ) ;
385+ var children = menuItem . children ;
386+ expect ( children [ 0 ] . nodeName ) . toBe ( 'MD-ICON' ) ;
387+ expect ( children [ 1 ] . nodeName ) . toBe ( 'MD-BUTTON' ) ;
388+ } ) ;
387389 it ( 'sets aria role' , function ( ) {
388390 var menuItem = setup ( ) [ 0 ] . querySelector ( 'md-button' ) ;
389391 expect ( menuItem . getAttribute ( 'role' ) ) . toBe ( 'menuitemradio' ) ;
@@ -417,27 +419,24 @@ describe('material.components.menuBar', function() {
417419 expect ( menuItem . children [ 0 ] . style . display ) . toBeFalsy ( ) ;
418420 expect ( button . getAttribute ( 'aria-checked' ) ) . toBe ( 'true' ) ;
419421 } ) ) ;
422+ } ) ;
420423
421- function setup ( attrs ) {
422- attrs = attrs || '' ;
423-
424- var template = '<md-menu-item type="radio" ' + attrs + '>Test Item</md-menu-item>' ;
425-
426- var radioMenuItem ;
427- inject ( function ( $compile , $rootScope ) {
428- // We need to have a `md-menu-bar` as a parent of our menu item, because the menu-item
429- // is only wrapping and indenting the content if it's inside of a menu bar.
430- var menuBarMock = angular . element ( '<md-menu-bar>' ) ;
431- var itemEl = angular . element ( template ) ;
424+ function setupMenuItem ( attrs ) {
425+ // We need to have a `md-menu-bar` as a parent of our menu item, because the menu-item
426+ // is only wrapping and indenting the content if it's inside of a menu bar.
427+ var menuBar ;
428+ var template =
429+ '<md-menu-bar>' +
430+ '<md-menu-item ' + ( attrs = attrs || '' ) + '>Test Item</md-menu-item>' +
431+ '</md-menu-bar>' ;
432432
433- menuBarMock . append ( itemEl ) ;
434- radioMenuItem = $compile ( itemEl ) ( $rootScope ) ;
433+ inject ( function ( $compile , $rootScope ) {
434+ menuBar = $compile ( template ) ( $rootScope ) ;
435+ $rootScope . $digest ( ) ;
436+ } ) ;
435437
436- $rootScope . $digest ( ) ;
437- } ) ;
438- return radioMenuItem ;
439- }
440- } ) ;
438+ return menuBar . find ( 'md-menu-item' ) ;
439+ }
441440 } ) ;
442441
443442 function waitForMenuOpen ( ) {
0 commit comments