0.17.7 • Published 6 years ago
tb-mocker v0.17.7
tb-mocker
Generate test data, company with tb-schema.
Currently Constructors:
- ✓ Activity
- ✓ Apprelation
- ✓ Collection
- ✓ Consumer
- ✓ Customfield
- ✓ Devicetoken
- ✓ Entry
- ✓ Event
- ✓ Feedback
- ✓ Group
- ✓ Integration
- ✓ Member
- ✓ Message
- ✓ Notice
- ✓ Organization
- ✓ Post
- ✓ Project
- ✓ Projecttemplate
- ✓ Rule
- ✓ Stage
- ✓ Subscriber
- ✓ Subtask
- ✓ Tag
- ✓ Task
- ✓ Tasklist
- ✓ Team
- ✓ Token
- ✓ User
- ✓ View
- ✓ Work
- ✓ Worktime
- ✓ Sprint
- ✓ tagcategory
API
mocker.Mocker
The base class.
mocker.constructors
console.log(mocker.constructors)
// [ 'Activity',
// 'Apprelation',
// 'Collection',
// 'Consumer',
// 'Customfield',
// 'Devicetoken',
// 'Entry',
// 'Event',
// 'Feedback',
// 'Integration',
// 'Member',
// 'Notice',
// 'Organization',
// 'Post',
// 'Project',
// 'Projecttemplate',
// 'Stage',
// 'Subscriber',
// 'Subtask',
// 'Smartgroup',
// 'Tag',
// 'Task',
// 'Tasklist',
// 'Team',
// 'Token',
// 'User',
// 'View',
// 'Work' ]
mockerconstructor , mockerConstructor , mockerConstructor + 'Model'
A example for User
:
mocker.user(): Return simple mocker user.
console.log(mocker.user()) // User { // name: 'name0', // email: 'email0@mocker.org', // emails: [ { email: 'email0@mocker.org', state: 0 } ], // password: 'sha1$303cee$d4b5b28cf8c06200000d890bd401a85a8b6556ed', // authUpdated: 1458818469463 }
mocker.user(obj): Return simple mocker user with custom data.
console.log(mocker.user({name: 'tester', email: 'tester@tb.com'})) // User { // name: 'tester', // email: 'tester@tb.com', // emails: [ { email: 'tester@tb.com', state: 0 } ], // password: 'sha1$303cee$d4b5b28cf8c06200000d890bd401a85a8b6556ed', // authUpdated: 1458818487941 }
new mocker.User(): Same as mocker.user().
new mocker.UserModel(mocker.user()): Return mongoose user model.
console.log(new mocker.UserModel(mocker.user())) // { emails: // [ { _id: 56f25241d4d16b31888c0e80, // state: 0, // email: 'email0@mocker.org' } ], // title: '', // location: '', // website: '', // created: Wed Mar 23 2016 16:22:25 GMT+0800 (CST), // updated: Wed Mar 23 2016 16:22:25 GMT+0800 (CST), // isActive: false, // isAdmin: false, // isBlock: false, // isPay: false, // latestActived: null, // hasLoginToday: false, // hasLoginTalk: false, // googleTwoFactor: null, // signUpIP: null, // signUpCity: null, // lastEntered: {}, // _id: 56f25241d4d16b31888c0e7f, // authUpdated: 1458721345492, // password: 'sha1$303cee$d4b5b28cf8c06200000d890bd401a85a8b6556ed', // email: 'email0@mocker.org', // name: 'name0' }
0.17.7
6 years ago