mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
Mock ENV function
This commit is contained in:
parent
b48be4e619
commit
cc68abb67e
1 changed files with 9 additions and 10 deletions
|
|
@ -27,30 +27,29 @@ describe.only('User Controller', function() {
|
|||
inject(function($rootScope, $controller, User, Content) {
|
||||
scope = $rootScope.$new();
|
||||
content = Content;
|
||||
$window = {
|
||||
env: {
|
||||
t: sandbox.stub(),
|
||||
},
|
||||
};
|
||||
$controller('RootCtrl', { $scope: scope, $window: $window, User: User});
|
||||
$controller('RootCtrl', { $scope: scope, User: User});
|
||||
ctrl = $controller('UserCtrl', { $scope: scope, User: User, $window: $window});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getProgressDisplay', function() {
|
||||
|
||||
beforeEach(() => {
|
||||
sandbox.stub(window.env, 't');
|
||||
window.env.t.onFirstCall().returns('Progress until next');
|
||||
});
|
||||
|
||||
it('should return initial progress', function() {
|
||||
$window.env.t.onFirstCall().returns('');
|
||||
scope.profile.loginIncentives = 0;
|
||||
content.loginIncentives = [{
|
||||
nextRewardAt: 1,
|
||||
reward: true
|
||||
}];
|
||||
var actual = scope.getProgressDisplay();
|
||||
expect(actual.trim()).to.eql('0/1');
|
||||
expect(actual.trim()).to.eql('Progress until next 0/1');
|
||||
});
|
||||
|
||||
it('should return progress between next reward and current reward', function() {
|
||||
$window.env.t.onFirstCall().returns('');
|
||||
scope.profile.loginIncentives = 1;
|
||||
content.loginIncentives = [{
|
||||
nextRewardAt: 1,
|
||||
|
|
@ -64,7 +63,7 @@ describe.only('User Controller', function() {
|
|||
nextRewardAt: 3
|
||||
}];
|
||||
var actual = scope.getProgressDisplay();
|
||||
expect(actual.trim()).to.eql('0/1');
|
||||
expect(actual.trim()).to.eql('Progress until next 0/1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue