Skip to content

Commit

Permalink
Merge pull request #42 from bartlomiejmont/handle-params
Browse files Browse the repository at this point in the history
Spread params into the context.bindingData
  • Loading branch information
dhensby authored Apr 20, 2023
2 parents 45214e7 + 15ca383 commit 3f22a4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bindings/http-binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function createHttpRequest(data: Partial<HttpRequest> = {}): HttpRequest {
}
throw new Error('multipart/form-data support not yet implemented');
},
...data.params,
}
}

Expand Down
15 changes: 15 additions & 0 deletions test/http-binding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,19 @@ describe('http-binding', () => {
const result = await functionRunner(functionStub, [{ name: 'myResponse', type: 'http', direction: 'out' }]);
expect(result).to.have.property('res', response);
});
it('executes an Http Trigger with params', async () => {
const req = { params: { id: 'testId' } };
const functionStub = stub().resolves();
const httpBinding = new HttpBinding(req);
const result = await functionRunner(
functionStub,
[
{ name: 'req', type: 'httpTrigger', direction: 'in' },
],
{ req: httpBinding },
);
expect(functionStub).to.have.been.calledOnceWithExactly(match.any, httpBinding.toContextBinding());
expect(result.bindingData.params.id).to.equal('testId')
expect(result.bindingData.params).to.deep.equal(req.params)
});
});

0 comments on commit 3f22a4d

Please sign in to comment.