scroll to top and load hero; add tests for new behavior.

This commit is contained in:
Blade Barringer
2015-04-10 23:51:34 -05:00
parent 24ef3aa012
commit 8642366f15
2 changed files with 10 additions and 0 deletions

View File

@@ -22,7 +22,15 @@ describe.only('Hall of Heroes Controller', function() {
}); });
it('populates contributor input with selected hero id', function(){ it('populates contributor input with selected hero id', function(){
var loadHero = sinon.spy(scope, "loadHero");
var scrollTo = sinon.spy(window, "scrollTo");
scope.populateContributorInput(user._id); scope.populateContributorInput(user._id);
expect(scope._heroID).to.eql(user._id); expect(scope._heroID).to.eql(user._id);
expect(loadHero.callCount).to.eql(1);
expect(scrollTo.callCount).to.eql(1);
scope.loadHero.restore();
window.scrollTo.restore();
}); });
}); });

View File

@@ -20,6 +20,8 @@ habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notifica
$scope.populateContributorInput = function(id) { $scope.populateContributorInput = function(id) {
$scope._heroID = id; $scope._heroID = id;
window.scrollTo(0,200);
$scope.loadHero(id);
}; };
}]); }]);