mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
tests(helpers): Add helper to generate user for common and content tests
This commit is contained in:
19
test/helpers/common.helper.js
Normal file
19
test/helpers/common.helper.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
import { wrap as wrapUser } from '../../common/script/index';
|
||||
import { model as User } from '../../website/src/models/user';
|
||||
import { TodoSchema } from '../../website/src/models/task';
|
||||
|
||||
export function generateUser (options = {}) {
|
||||
let user = new User(options).toObject();
|
||||
|
||||
wrapUser(user);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
export function generateTodo (options = {}) {
|
||||
let Todo = mongoose.model('Todo', TodoSchema);
|
||||
|
||||
return new Todo(options).toObject();
|
||||
}
|
||||
Reference in New Issue
Block a user