Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const $internals = {
- hystrix: (...){},
- runCmd: (...){},
- init: (options) => {
- /* Setup logger */
- $internals.log = wsLogger(options.constants);
- /* Setup Hystrix functions */
- const hystrixFunctions = $internals.hystrix(options, client);
- return {
- registrationUser: (req, data) => {
- return $internals.runCmd({
- endpoint: 'registrationUser',
- req,
- data,
- executeFn: hystrixFunctions.hRegistrationUser
- });
- }
- };
- }
- }
- module.exports = (options = {}) => {
- if (Object.keys(options).length === 0)
- options = $default;
- assert(options);
- assert(options.constants);
- return $internals.init(options);
- };
- ...
- const registrationService = require('../service/service');
- ...
- describe('POST /api/v1/user', () => {
- it.only('should register new user', (done) => {
- const userRegistration = sinon.stub(registrationService, 'registrationUser');
- const params = {
- name: 'Dummy Name',
- number: '8726853453',
- password: 'myTestPass',
- verificationMode: 'OTP',
- otp: 'otp',
- sim: 'sim',
- email: 'user.me@io',
- code: 'code',
- answer: 'answer'
- }
- request(server)
- .post('/api/v1/user')
- .set('Content-Type', 'application/json')
- .send(params)
- .end((err, res) => {
- should.not.exist(err);
- sinon.assert.calledOnce(userRegistration);
- done();
- });
- })
- })
Add Comment
Please, Sign In to add comment