mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Use select instead of an input for cds
This commit is contained in:
@@ -31,27 +31,6 @@ describe('Settings Controller', function() {
|
|||||||
sandbox.stub(window, 'alert');
|
sandbox.stub(window, 'alert');
|
||||||
});
|
});
|
||||||
|
|
||||||
context('failures', function() {
|
|
||||||
var tests = {
|
|
||||||
'blank': '',
|
|
||||||
'not a whole number': 5.3,
|
|
||||||
'not a number': 'foo',
|
|
||||||
'less than 0': -5,
|
|
||||||
'more than 24': 25
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var test in tests) {
|
|
||||||
it('returns with an alert if number is ' + test, function() {
|
|
||||||
scope.openDayStartModal(tests[test]);
|
|
||||||
|
|
||||||
expect(rootScope.openModal).to.not.be.called;
|
|
||||||
expect(window.alert).to.be.calledOnce;
|
|
||||||
expect(window.alert).to.be.calledWith(env.t('enterNumber'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
context('success', function() {
|
|
||||||
it('opens the day start modal', function() {
|
it('opens the day start modal', function() {
|
||||||
scope.openDayStartModal(5);
|
scope.openDayStartModal(5);
|
||||||
|
|
||||||
@@ -87,12 +66,10 @@ describe('Settings Controller', function() {
|
|||||||
expect(scope.nextCron).to.eq(expectedTime);
|
expect(scope.nextCron).to.eq(expectedTime);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('#saveDayStart', function() {
|
describe('#saveDayStart', function() {
|
||||||
|
|
||||||
it('updates user\'s custom day start and last cron', function() {
|
it('updates user\'s custom day start and last cron', function() {
|
||||||
|
|
||||||
var fakeCurrentTime = new Date(2013, 3, 1, 8, 12).getTime();
|
var fakeCurrentTime = new Date(2013, 3, 1, 8, 12).getTime();
|
||||||
var expectedTime = fakeCurrentTime;
|
var expectedTime = fakeCurrentTime;
|
||||||
sandbox.useFakeTimers(fakeCurrentTime);
|
sandbox.useFakeTimers(fakeCurrentTime);
|
||||||
|
|||||||
@@ -66,12 +66,6 @@ habitrpg.controller('SettingsCtrl',
|
|||||||
|
|
||||||
$scope.openDayStartModal = function(dayStart) {
|
$scope.openDayStartModal = function(dayStart) {
|
||||||
$scope.dayStart = +dayStart;
|
$scope.dayStart = +dayStart;
|
||||||
var flooredDayStart = Math.floor($scope.dayStart);
|
|
||||||
|
|
||||||
if ($scope.dayStart !== flooredDayStart || $scope.dayStart < 0 || $scope.dayStart > 24 ) {
|
|
||||||
return alert(window.env.t('enterNumber'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.nextCron = _calculateNextCron();
|
$scope.nextCron = _calculateNextCron();
|
||||||
|
|
||||||
$rootScope.openModal('change-day-start', { scope: $scope });
|
$rootScope.openModal('change-day-start', { scope: $scope });
|
||||||
|
|||||||
@@ -97,9 +97,10 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
|
|||||||
select.form-control(ng-model='dayStart')
|
select.form-control(ng-model='dayStart')
|
||||||
- var number = 0
|
- var number = 0
|
||||||
while number < 24
|
while number < 24
|
||||||
- var hour = number++ % 12
|
- var value = number
|
||||||
- var meridian = number < 12 ? 'AM' : 'PM'
|
- var meridian = number < 12 ? 'AM' : 'PM'
|
||||||
option(value=number) #{hour ? hour : 12}:00 #{meridian}
|
- var hour = number++ % 12
|
||||||
|
option(value=value) #{hour ? hour : 12}:00 #{meridian}
|
||||||
|
|
||||||
.col-sm-5
|
.col-sm-5
|
||||||
br.visible-xs
|
br.visible-xs
|
||||||
|
|||||||
Reference in New Issue
Block a user