We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this is my tested file:
var restConfigUtil = require('../../../../common/utilities/rest-configuration-utility'), restService = require('../../../../base/services/falcon-rest-service'), querystring = require('querystring'); module.exports = function getPostUnpostResources(req, callback) { var restConfig = restConfigUtil.createWfcAuthenticatedRestConfig('schedule.postunpost.resources', req); restConfig.path += '?' + querystring.stringify(req.body.params); restService.executeHttpRequestAsync(restConfig, req.body.data).then(function (data) { callback(null, data); }, function(err) { callback(err); }); };
and this is test:
var should = require('should'), sinon = require('sinon'), Promise = require('bluebird'), mockrequire = require('mockrequire'); describe('Schedule - Action - post-unpost - resources', function() { describe('get function', function() { var callbackSpy, data = ['foo'], error = {message: 'some error!'}, controller; //beforeAll before(function() { var resolvedPromise = Promise.resolve(data), rejectedPromise = Promise.reject(error); var mockedCall = sinon.stub(); mockedCall.onCall(0).returns(resolvedPromise); mockedCall.onCall(1).returns(rejectedPromise); var mockCreateConfig = sinon.stub(); mockCreateConfig.returns({path: ''}); controller = mockrequire('../../schedule/controller/actions/post-unpost/resources', { '../../../../common/utilities/rest-configuration-utility': { executeHttpRequestAsync: mockedCall }, '../../../../base/services/falcon-rest-service': { createWfcAuthenticatedRestConfig: mockCreateConfig } }); }); beforeEach(function() { callbackSpy = sinon.spy(); }); it('should call callback with data returned from backend in case of success', function() { try { controller({}, callbackSpy); } catch(e) { throw Error(e.message); } callbackSpy.args[0].should.be.exactly([null, data]); });
Test fails with error: Error: restConfigUtil.createWfcAuthenticatedRestConfig is not a function
Error: restConfigUtil.createWfcAuthenticatedRestConfig is not a function
What am I doing wrong?
The text was updated successfully, but these errors were encountered:
Your mocked functions don't match the modules your mocking. You have them flipped. Looks like you want:
controller = mockrequire('../index', { '../../../../common/utilities/rest-configuration-utility': { createWfcAuthenticatedRestConfig: mockCreateConfig }, '../../../../base/services/falcon-rest-service': { executeHttpRequestAsync: mockedCall }
Sorry, something went wrong.
No branches or pull requests
this is my tested file:
and this is test:
Test fails with error:
Error: restConfigUtil.createWfcAuthenticatedRestConfig is not a function
What am I doing wrong?
The text was updated successfully, but these errors were encountered: