Guest User

Untitled

a guest
Mar 26th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. const $internals = {
  2. hystrix: (...){},
  3. runCmd: (...){},
  4. init: (options) => {
  5.  
  6. /* Setup logger */
  7. $internals.log = wsLogger(options.constants);
  8. /* Setup Hystrix functions */
  9. const hystrixFunctions = $internals.hystrix(options, client);
  10.  
  11. return {
  12. registrationUser: (req, data) => {
  13. return $internals.runCmd({
  14. endpoint: 'registrationUser',
  15. req,
  16. data,
  17. executeFn: hystrixFunctions.hRegistrationUser
  18. });
  19. }
  20. };
  21. }
  22. }
  23.  
  24. module.exports = (options = {}) => {
  25.  
  26. if (Object.keys(options).length === 0)
  27. options = $default;
  28.  
  29. assert(options);
  30. assert(options.constants);
  31.  
  32. return $internals.init(options);
  33. };
  34.  
  35. ...
  36. const registrationService = require('../service/service');
  37. ...
  38.  
  39. describe('POST /api/v1/user', () => {
  40. it.only('should register new user', (done) => {
  41. const userRegistration = sinon.stub(registrationService, 'registrationUser');
  42. const params = {
  43. name: 'Dummy Name',
  44. number: '8726853453',
  45. password: 'myTestPass',
  46. verificationMode: 'OTP',
  47. otp: 'otp',
  48. sim: 'sim',
  49. email: 'user.me@io',
  50. code: 'code',
  51. answer: 'answer'
  52. }
  53. request(server)
  54. .post('/api/v1/user')
  55. .set('Content-Type', 'application/json')
  56. .send(params)
  57. .end((err, res) => {
  58. should.not.exist(err);
  59. sinon.assert.calledOnce(userRegistration);
  60. done();
  61. });
  62. })
  63. })
Add Comment
Please, Sign In to add comment