mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Added tests for challenge task scoring and moved scoring code to model
This commit is contained in:
@@ -4,6 +4,7 @@ import { defaultsDeep as defaults } from 'lodash';
|
||||
import { model as User } from '../../website/src/models/user';
|
||||
import { model as Group } from '../../website/src/models/group';
|
||||
import mongo from './mongo'; // eslint-disable-line
|
||||
import moment from 'moment';
|
||||
|
||||
afterEach((done) => {
|
||||
sandbox.restore();
|
||||
@@ -48,3 +49,18 @@ export function generateReq (options = {}) {
|
||||
export function generateNext (func) {
|
||||
return func || sandbox.stub();
|
||||
}
|
||||
|
||||
export function generateHistory (days) {
|
||||
let history = [];
|
||||
let now = Number(moment().toDate());
|
||||
|
||||
while (days > 0) {
|
||||
history.push({
|
||||
value: days,
|
||||
date: Number(moment(now).subtract(days, 'days').toDate()),
|
||||
});
|
||||
days--;
|
||||
}
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user