mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-05 13:33:00 +00:00
tests(helpers): Add helper to generate user for common and content tests
This commit is contained in:
parent
dafe014ec8
commit
70751abe01
1 changed files with 19 additions and 0 deletions
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();
|
||||
}
|
||||
Loading…
Reference in a new issue