Skip to content

Commit

Permalink
Merge d5a8046 into 957929e
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal2228 committed Jan 13, 2018
2 parents 957929e + d5a8046 commit a76cf00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/router/router-execution-context.ts
Expand Up @@ -97,7 +97,7 @@ export class RouterExecutionContext {
callback,
handler,
);
isResponseHandled && this.responseController.apply(result, res, httpStatusCode)
!isResponseHandled && this.responseController.apply(result, res, httpStatusCode)
};
}

Expand Down
22 changes: 14 additions & 8 deletions src/core/test/router/router-execution-context.spec.ts
Expand Up @@ -52,7 +52,6 @@ describe('RouterExecutionContext', () => {
let exchangeKeysForValuesSpy: sinon.SinonSpy;
beforeEach(() => {
metadata = {
[RouteParamtypes.NEXT]: { index: 0 },
[RouteParamtypes.BODY]: {
index: 2,
data: 'test',
Expand Down Expand Up @@ -91,12 +90,7 @@ describe('RouterExecutionContext', () => {
expect(proxyContext).to.be.a('function');
});
describe('when proxy function called', () => {
let request;
const response = {
status: () => response,
send: () => response,
json: () => response,
};
let request, response, jsonSpy, sendSpy, statusStub;
const next = {};

beforeEach(() => {
Expand All @@ -105,12 +99,24 @@ describe('RouterExecutionContext', () => {
test: 3,
},
};
jsonSpy = sinon.stub().returns({});
sendSpy = sinon.stub().returns({});
statusStub = sinon.stub().returns({
json: jsonSpy,
send: sendSpy
});
response = {
status: statusStub
};
});
it('should apply expected context and arguments to callback', done => {
proxyContext(request, response, next).then(() => {
const args = [next, null, request.body.test];
const args = [null, null, request.body.test];
expect(applySpy.called).to.be.true;
expect(applySpy.calledWith(instance, args)).to.be.true;
expect(statusStub.called).to.be.true;
expect(jsonSpy.called).to.be.true;
expect(sendSpy.called).to.be.false;
done();
});
});
Expand Down

0 comments on commit a76cf00

Please sign in to comment.