0.17.7 • Published 6 years ago

tb-mocker v0.17.7

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

tb-mocker

Generate test data, company with tb-schema.

Currently Constructors:

  1. ✓ Activity
  2. ✓ Apprelation
  3. ✓ Collection
  4. ✓ Consumer
  5. ✓ Customfield
  6. ✓ Devicetoken
  7. ✓ Entry
  8. ✓ Event
  9. ✓ Feedback
  10. ✓ Group
  11. ✓ Integration
  12. ✓ Member
  13. ✓ Message
  14. ✓ Notice
  15. ✓ Organization
  16. ✓ Post
  17. ✓ Project
  18. ✓ Projecttemplate
  19. ✓ Rule
  20. ✓ Stage
  21. ✓ Subscriber
  22. ✓ Subtask
  23. ✓ Tag
  24. ✓ Task
  25. ✓ Tasklist
  26. ✓ Team
  27. ✓ Token
  28. ✓ User
  29. ✓ View
  30. ✓ Work
  31. ✓ Worktime
  32. ✓ Sprint
  33. ✓ 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