mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
scroll to top and load hero; add tests for new behavior.
This commit is contained in:
@@ -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();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user