@@ -72,23 +72,72 @@ describe('md-menu directive', function () {
72
72
expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
73
73
} ) ) ;
74
74
75
- it ( 'closes on option click' , function ( ) {
76
- expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
75
+ describe ( 'closes with ng-click' , function ( ) {
76
+ it ( 'closes on normal option click' , function ( ) {
77
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
77
78
78
- openMenu ( setup ( ) ) ;
79
+ openMenu ( setup ( ) ) ;
79
80
80
- expect ( something ) . toBeFalsy ( ) ;
81
- expect ( getOpenMenuContainer ( ) . length ) . toBe ( 1 ) ;
81
+ expect ( something ) . toBeFalsy ( ) ;
82
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 1 ) ;
82
83
83
- var btn = angular . element ( getOpenMenuContainer ( ) [ 0 ] . querySelector ( 'md-button' ) ) ;
84
- btn . triggerHandler ( { type : ' click' } ) ;
84
+ var btn = getOpenMenuContainer ( ) [ 0 ] . querySelector ( 'md-button' ) ;
85
+ btn . click ( ) ;
85
86
86
- waitForMenuClose ( ) ;
87
+ waitForMenuClose ( ) ;
88
+
89
+ expect ( something ) . toBeTruthy ( ) ;
90
+
91
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
92
+ } ) ;
93
+
94
+ it ( 'closes with data-ng-click' , inject ( function ( $rootScope , $compile ) {
95
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
96
+
97
+ var template = '' +
98
+ '<md-menu>' +
99
+ ' <button ng-click="$mdOpenMenu($event)">Hello World</button>' +
100
+ ' <md-menu-content>' +
101
+ ' <md-menu-item>' +
102
+ ' <md-button data-ng-click="doSomething($event)"></md-button>' +
103
+ ' </md-menu-item>' +
104
+ ' </md-menu-content>' +
105
+ '</md-menu>' ;
87
106
88
- expect ( something ) . toBeTruthy ( ) ;
107
+ openMenu ( $compile ( template ) ( $rootScope ) ) ;
108
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 1 ) ;
109
+
110
+ var btn = getOpenMenuContainer ( ) [ 0 ] . querySelector ( 'md-button' ) ;
111
+ btn . click ( ) ;
112
+
113
+ waitForMenuClose ( ) ;
114
+
115
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
116
+ } ) ) ;
117
+
118
+ it ( 'closes with x-ng-click' , inject ( function ( $rootScope , $compile ) {
119
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
120
+
121
+ var template = '' +
122
+ '<md-menu>' +
123
+ ' <button ng-click="$mdOpenMenu($event)">Hello World</button>' +
124
+ ' <md-menu-content>' +
125
+ ' <md-menu-item>' +
126
+ ' <md-button x-ng-click="doSomething($event)"></md-button>' +
127
+ ' </md-menu-item>' +
128
+ ' </md-menu-content>' +
129
+ '</md-menu>' ;
130
+
131
+ openMenu ( $compile ( template ) ( $rootScope ) ) ;
132
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 1 ) ;
133
+
134
+ var btn = getOpenMenuContainer ( ) [ 0 ] . querySelector ( 'md-button' ) ;
135
+ btn . click ( ) ;
136
+
137
+ waitForMenuClose ( ) ;
89
138
90
- // FIXME - why is the menu not auto-closing ?
91
- //expect(getOpenMenuContainer().length).toBe(0 );
139
+ expect ( getOpenMenuContainer ( ) . length ) . toBe ( 0 ) ;
140
+ } ) ) ;
92
141
} ) ;
93
142
94
143
// ********************************************
0 commit comments