Skip to content

Commit 86eacac

Browse files
committed
fix(uiView): autoscroll tests pass on 1.2.4 & 1.1.5
1 parent 83b6634 commit 86eacac

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Gruntfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ module.exports = function (grunt) {
8989
browsers: [ grunt.option('browser') || 'Chrome' ]
9090
},
9191
past: {
92-
configFile: 'config/karma-1.0.8.js',
92+
configFile: 'config/karma-1.0.8.js'
9393
},
9494
unstable: {
95-
configFile: 'config/karma-1.1.5.js',
95+
configFile: 'config/karma-1.1.5.js'
9696
}
9797
},
9898
changelog: {

test/viewDirectiveSpec.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,20 @@ describe('uiView', function () {
271271
});
272272

273273
describe('autoscroll attribute', function () {
274-
it('should autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll) {
274+
it('should autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll, $animate) {
275275
elem.append($compile('<div><ui-view></ui-view></div>')(scope));
276276
$state.transitionTo(aState);
277277
$q.flush();
278-
expect($uiViewScroll).toHaveBeenCalledWith(elem.find('ui-view'));
278+
if ($animate) $animate.flush();
279+
expect($uiViewScroll).toHaveBeenCalledWith(elem.find('span').parent());
279280
}));
280281

281-
it('should autoscroll when expression is missing', inject(function ($state, $q, $uiViewScroll) {
282+
it('should autoscroll when expression is missing', inject(function ($state, $q, $uiViewScroll, $animate) {
282283
elem.append($compile('<div><ui-view autoscroll></ui-view></div>')(scope));
283284
$state.transitionTo(aState);
284285
$q.flush();
285-
expect($uiViewScroll).toHaveBeenCalledWith(elem.find('ui-view'));
286+
if ($animate) $animate.flush();
287+
expect($uiViewScroll).toHaveBeenCalledWith(elem.find('span').parent());
286288
}));
287289

288290
it('should autoscroll based on expression', inject(function ($state, $q, $uiViewScroll, $animate) {
@@ -298,7 +300,12 @@ describe('uiView', function () {
298300
$q.flush();
299301
if ($animate) $animate.flush();
300302

301-
expect($uiViewScroll).toHaveBeenCalledWith(elem.find('ui-view'));
303+
var target;
304+
angular.forEach(elem.find('ui-view'), function(view) {
305+
if (angular.element(view).text() === bState.template) target = angular.element(view);
306+
});
307+
308+
expect($uiViewScroll).toHaveBeenCalledWith(target);
302309
}));
303310
});
304311

0 commit comments

Comments
 (0)