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,68 +31,45 @@ describe('Settings Controller', function() {
|
||||
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
|
||||
};
|
||||
it('opens the day start modal', function() {
|
||||
scope.openDayStartModal(5);
|
||||
|
||||
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'));
|
||||
});
|
||||
}
|
||||
expect(rootScope.openModal).to.be.calledOnce;
|
||||
expect(rootScope.openModal).to.be.calledWith('change-day-start', {scope: scope});
|
||||
});
|
||||
|
||||
context('success', function() {
|
||||
it('opens the day start modal', function() {
|
||||
scope.openDayStartModal(5);
|
||||
it('sets nextCron variable', function() {
|
||||
expect(scope.nextCron).to.not.exist;
|
||||
|
||||
expect(rootScope.openModal).to.be.calledOnce;
|
||||
expect(rootScope.openModal).to.be.calledWith('change-day-start', {scope: scope});
|
||||
});
|
||||
scope.openDayStartModal(5);
|
||||
|
||||
it('sets nextCron variable', function() {
|
||||
expect(scope.nextCron).to.not.exist;
|
||||
expect(scope.nextCron).to.exist;
|
||||
});
|
||||
|
||||
scope.openDayStartModal(5);
|
||||
it('calculates the next time cron will run', function() {
|
||||
var fakeCurrentTime = new Date(2013, 3, 1, 3, 12).getTime();
|
||||
var expectedTime = new Date(2013, 3, 1, 5, 0, 0).getTime();
|
||||
sandbox.useFakeTimers(fakeCurrentTime);
|
||||
|
||||
expect(scope.nextCron).to.exist;
|
||||
});
|
||||
scope.openDayStartModal(5);
|
||||
|
||||
it('calculates the next time cron will run', function() {
|
||||
var fakeCurrentTime = new Date(2013, 3, 1, 3, 12).getTime();
|
||||
var expectedTime = new Date(2013, 3, 1, 5, 0, 0).getTime();
|
||||
sandbox.useFakeTimers(fakeCurrentTime);
|
||||
expect(scope.nextCron).to.eq(expectedTime);
|
||||
});
|
||||
|
||||
scope.openDayStartModal(5);
|
||||
it('calculates the next time cron will run and adds a day if cron would have already passed', function() {
|
||||
var fakeCurrentTime = new Date(2013, 3, 1, 8, 12).getTime();
|
||||
var expectedTime = new Date(2013, 3, 2, 5, 0, 0).getTime();
|
||||
sandbox.useFakeTimers(fakeCurrentTime);
|
||||
|
||||
expect(scope.nextCron).to.eq(expectedTime);
|
||||
});
|
||||
scope.openDayStartModal(5);
|
||||
|
||||
it('calculates the next time cron will run and adds a day if cron would have already passed', function() {
|
||||
var fakeCurrentTime = new Date(2013, 3, 1, 8, 12).getTime();
|
||||
var expectedTime = new Date(2013, 3, 2, 5, 0, 0).getTime();
|
||||
sandbox.useFakeTimers(fakeCurrentTime);
|
||||
|
||||
scope.openDayStartModal(5);
|
||||
|
||||
expect(scope.nextCron).to.eq(expectedTime);
|
||||
});
|
||||
expect(scope.nextCron).to.eq(expectedTime);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#saveDayStart', function() {
|
||||
|
||||
it('updates user\'s custom day start and last cron', function() {
|
||||
|
||||
var fakeCurrentTime = new Date(2013, 3, 1, 8, 12).getTime();
|
||||
var expectedTime = fakeCurrentTime;
|
||||
sandbox.useFakeTimers(fakeCurrentTime);
|
||||
|
||||
Reference in New Issue
Block a user