Added tests for challenge task scoring and moved scoring code to model

This commit is contained in:
Keith Holliday
2016-03-18 14:00:14 -05:00
parent 99ff440abc
commit b46219adc5
6 changed files with 265 additions and 42 deletions

View File

@@ -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;
}