mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
tests(helpers): Add common helpers for generating tasks
This commit is contained in:
@@ -2,7 +2,12 @@ import mongoose from 'mongoose';
|
|||||||
|
|
||||||
import { wrap as wrapUser } from '../../common/script/index';
|
import { wrap as wrapUser } from '../../common/script/index';
|
||||||
import { model as User } from '../../website/src/models/user';
|
import { model as User } from '../../website/src/models/user';
|
||||||
import { TodoSchema } from '../../website/src/models/task';
|
import {
|
||||||
|
DailySchema,
|
||||||
|
HabitSchema,
|
||||||
|
RewardSchema,
|
||||||
|
TodoSchema,
|
||||||
|
} from '../../website/src/models/task';
|
||||||
|
|
||||||
export function generateUser (options = {}) {
|
export function generateUser (options = {}) {
|
||||||
let user = new User(options).toObject();
|
let user = new User(options).toObject();
|
||||||
@@ -12,6 +17,24 @@ export function generateUser (options = {}) {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function generateDaily (options = {}) {
|
||||||
|
let Daily = mongoose.model('Daily', DailySchema);
|
||||||
|
|
||||||
|
return new Daily(options).toObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function generateHabit (options = {}) {
|
||||||
|
let Habit = mongoose.model('Habit', HabitSchema);
|
||||||
|
|
||||||
|
return new Habit(options).toObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function generateReward (options = {}) {
|
||||||
|
let Reward = mongoose.model('Reward', RewardSchema);
|
||||||
|
|
||||||
|
return new Reward(options).toObject();
|
||||||
|
}
|
||||||
|
|
||||||
export function generateTodo (options = {}) {
|
export function generateTodo (options = {}) {
|
||||||
let Todo = mongoose.model('Todo', TodoSchema);
|
let Todo = mongoose.model('Todo', TodoSchema);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user