mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
rever new history preening
This commit is contained in:
@@ -990,6 +990,124 @@ describe('Cron', () => {
|
||||
expect(beforeTasks).to.eql(afterTasks);
|
||||
});
|
||||
|
||||
describe('preening', () => {
|
||||
beforeEach(function () {
|
||||
this.clock = sinon.useFakeTimers(Date.parse('2013-11-20'), 'Date');
|
||||
});
|
||||
afterEach(function () {
|
||||
return this.clock.restore();
|
||||
});
|
||||
|
||||
it('should preen user history', function () {
|
||||
let ref = beforeAfter({
|
||||
daysAgo: 1,
|
||||
});
|
||||
let after = ref.after;
|
||||
|
||||
let history = [
|
||||
{
|
||||
date: '09/01/2012',
|
||||
value: 0,
|
||||
}, {
|
||||
date: '10/01/2012',
|
||||
value: 0,
|
||||
}, {
|
||||
date: '11/01/2012',
|
||||
value: 2,
|
||||
}, {
|
||||
date: '12/01/2012',
|
||||
value: 2,
|
||||
}, {
|
||||
date: '01/01/2013',
|
||||
value: 1,
|
||||
}, {
|
||||
date: '01/15/2013',
|
||||
value: 3,
|
||||
}, {
|
||||
date: '02/01/2013',
|
||||
value: 2,
|
||||
}, {
|
||||
date: '02/15/2013',
|
||||
value: 4,
|
||||
}, {
|
||||
date: '03/01/2013',
|
||||
value: 3,
|
||||
}, {
|
||||
date: '03/15/2013',
|
||||
value: 5,
|
||||
}, {
|
||||
date: '04/01/2013',
|
||||
value: 4,
|
||||
}, {
|
||||
date: '04/15/2013',
|
||||
value: 6,
|
||||
}, {
|
||||
date: '05/01/2013',
|
||||
value: 5,
|
||||
}, {
|
||||
date: '05/15/2013',
|
||||
value: 7,
|
||||
}, {
|
||||
date: '06/01/2013',
|
||||
value: 6,
|
||||
}, {
|
||||
date: '06/15/2013',
|
||||
value: 8,
|
||||
}, {
|
||||
date: '07/01/2013',
|
||||
value: 7,
|
||||
}, {
|
||||
date: '07/15/2013',
|
||||
value: 9,
|
||||
}, {
|
||||
date: '08/01/2013',
|
||||
value: 8,
|
||||
}, {
|
||||
date: '08/15/2013',
|
||||
value: 10,
|
||||
}, {
|
||||
date: '09/01/2013',
|
||||
value: 9,
|
||||
}, {
|
||||
date: '09/15/2013',
|
||||
value: 11,
|
||||
}, {
|
||||
date: '010/01/2013',
|
||||
value: 10,
|
||||
}, {
|
||||
date: '010/15/2013',
|
||||
value: 12,
|
||||
}, {
|
||||
date: '011/01/2013',
|
||||
value: 12,
|
||||
}, {
|
||||
date: '011/02/2013',
|
||||
value: 13,
|
||||
}, {
|
||||
date: '011/03/2013',
|
||||
value: 14,
|
||||
}, {
|
||||
date: '011/04/2013',
|
||||
value: 15,
|
||||
},
|
||||
];
|
||||
|
||||
after.history = {
|
||||
exp: _.cloneDeep(history),
|
||||
todos: _.cloneDeep(history),
|
||||
};
|
||||
after.habits[0].history = _.cloneDeep(history);
|
||||
after.fns.cron();
|
||||
after.history.exp.pop();
|
||||
after.history.todos.pop();
|
||||
_.each([after.history.exp, after.history.todos, after.habits[0].history], function (arr) {
|
||||
expect(_.map(arr, (x) => {
|
||||
return x.value;
|
||||
})).to.eql([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Todos', () => {
|
||||
it('1 day missed', () => {
|
||||
let ref = beforeAfter({
|
||||
|
||||
Reference in New Issue
Block a user