@@ -49,9 +49,10 @@ describe('$anchorScroll', function() {
49
49
} ;
50
50
}
51
51
52
- function callAnchorScroll ( ) {
52
+ function callAnchorScroll ( hash ) {
53
+ var args = arguments ;
53
54
return function ( $anchorScroll ) {
54
- $anchorScroll ( ) ;
55
+ $anchorScroll . apply ( null , args ) ;
55
56
} ;
56
57
}
57
58
@@ -136,55 +137,58 @@ describe('$anchorScroll', function() {
136
137
} ) ) ;
137
138
138
139
139
- describe ( 'when explicitly called ' , function ( ) {
140
+ describe ( 'when implicitly using `$location.hash()` ' , function ( ) {
140
141
141
142
beforeEach ( createMockWindow ( ) ) ;
142
143
143
144
144
- it ( 'should scroll to top of the window if empty hash' , inject (
145
- changeHashAndScroll ( '' ) ,
146
- expectScrollingToTop ) ) ;
145
+ describe ( 'and no hash is specified' , function ( ) {
146
+
147
+ it ( 'should scroll to top of the window if empty hash' , inject (
148
+ changeHashAndScroll ( '' ) ,
149
+ expectScrollingToTop ) ) ;
147
150
148
151
149
- it ( 'should not scroll if hash does not match any element' , inject (
150
- addElements ( 'id=one' , 'id=two' ) ,
151
- changeHashAndScroll ( 'non-existing' ) ,
152
- expectNoScrolling ( ) ) ) ;
152
+ it ( 'should not scroll if hash does not match any element' , inject (
153
+ addElements ( 'id=one' , 'id=two' ) ,
154
+ changeHashAndScroll ( 'non-existing' ) ,
155
+ expectNoScrolling ( ) ) ) ;
153
156
154
157
155
- it ( 'should scroll to anchor element with name' , inject (
156
- addElements ( 'a name=abc' ) ,
157
- changeHashAndScroll ( 'abc' ) ,
158
- expectScrollingTo ( 'a name=abc' ) ) ) ;
158
+ it ( 'should scroll to anchor element with name' , inject (
159
+ addElements ( 'a name=abc' ) ,
160
+ changeHashAndScroll ( 'abc' ) ,
161
+ expectScrollingTo ( 'a name=abc' ) ) ) ;
159
162
160
163
161
- it ( 'should not scroll to other than anchor element with name' , inject (
162
- addElements ( 'input name=xxl' , 'select name=xxl' , 'form name=xxl' ) ,
163
- changeHashAndScroll ( 'xxl' ) ,
164
- expectNoScrolling ( ) ) ) ;
164
+ it ( 'should not scroll to other than anchor element with name' , inject (
165
+ addElements ( 'input name=xxl' , 'select name=xxl' , 'form name=xxl' ) ,
166
+ changeHashAndScroll ( 'xxl' ) ,
167
+ expectNoScrolling ( ) ) ) ;
165
168
166
169
167
- it ( 'should scroll to anchor even if other element with given name exist' , inject (
168
- addElements ( 'input name=some' , 'a name=some' ) ,
169
- changeHashAndScroll ( 'some' ) ,
170
- expectScrollingTo ( 'a name=some' ) ) ) ;
170
+ it ( 'should scroll to anchor even if other element with given name exist' , inject (
171
+ addElements ( 'input name=some' , 'a name=some' ) ,
172
+ changeHashAndScroll ( 'some' ) ,
173
+ expectScrollingTo ( 'a name=some' ) ) ) ;
171
174
172
175
173
- it ( 'should scroll to element with id with precedence over name' , inject (
174
- addElements ( 'name=abc' , 'id=abc' ) ,
175
- changeHashAndScroll ( 'abc' ) ,
176
- expectScrollingTo ( 'id=abc' ) ) ) ;
176
+ it ( 'should scroll to element with id with precedence over name' , inject (
177
+ addElements ( 'name=abc' , 'id=abc' ) ,
178
+ changeHashAndScroll ( 'abc' ) ,
179
+ expectScrollingTo ( 'id=abc' ) ) ) ;
177
180
178
181
179
- it ( 'should scroll to top if hash == "top" and no matching element' , inject (
180
- changeHashAndScroll ( 'top' ) ,
181
- expectScrollingToTop ) ) ;
182
+ it ( 'should scroll to top if hash == "top" and no matching element' , inject (
183
+ changeHashAndScroll ( 'top' ) ,
184
+ expectScrollingToTop ) ) ;
182
185
183
186
184
- it ( 'should scroll to element with id "top" if present' , inject (
185
- addElements ( 'id=top' ) ,
186
- changeHashAndScroll ( 'top' ) ,
187
- expectScrollingTo ( 'id=top' ) ) ) ;
187
+ it ( 'should scroll to element with id "top" if present' , inject (
188
+ addElements ( 'id=top' ) ,
189
+ changeHashAndScroll ( 'top' ) ,
190
+ expectScrollingTo ( 'id=top' ) ) ) ;
191
+ } ) ;
188
192
} ) ;
189
193
190
194
0 commit comments