Skip to content

Commit 43b0f13

Browse files
author
Guido Nebiolo
committed
[issue-72] test case for multiValueQueryStringParameters support
1 parent 0bce299 commit 43b0f13

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/routes.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ describe('Route Tests:', function() {
288288
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"get","status":"ok","param":"123","query":"321"}', isBase64Encoded: false })
289289
}) // end it
290290

291+
it('Path with parameter and multiple querystring: /test/123/query/?test=123&test=321', async function() {
292+
let _event = Object.assign({},event,{ path: '/test/123/query', queryStringParameters: { test: ['123', '321'] } })
293+
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
294+
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"get","status":"ok","param":"123","query":["123","321"]}', isBase64Encoded: false })
295+
}) // end it
296+
291297
it('Path with multiple parameters and querystring: /test/123/query/456/?test=321', async function() {
292298
let _event = Object.assign({},event,{ path: '/test/123/query/456', queryStringParameters: { test: '321' } })
293299
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
@@ -364,6 +370,12 @@ describe('Route Tests:', function() {
364370
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '', isBase64Encoded: false })
365371
}) // end it
366372

373+
it('Path with parameter and multiple querystring: /test/123/query/?test=123&test=321', async function() {
374+
let _event = Object.assign({},event,{ path: '/test/123/query', httpMethod: 'head', queryStringParameters: { test: ['123', '321'] } })
375+
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
376+
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '', isBase64Encoded: false })
377+
}) // end it
378+
367379
it('Path with multiple parameters and querystring: /test/123/query/456/?test=321', async function() {
368380
let _event = Object.assign({},event,{ path: '/test/123/query/456', httpMethod: 'head', queryStringParameters: { test: '321' } })
369381
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
@@ -432,6 +444,12 @@ describe('Route Tests:', function() {
432444
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"post","status":"ok","param":"123","query":"321"}', isBase64Encoded: false })
433445
}) // end it
434446

447+
it('Path with parameter and multiple querystring: /test/123/query/?test=123&test=321', async function() {
448+
let _event = Object.assign({},event,{ path: '/test/123/query', httpMethod: 'post', queryStringParameters: { test: ['123', '321'] } })
449+
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
450+
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"post","status":"ok","param":"123","query":["123","321"]}', isBase64Encoded: false })
451+
}) // end it
452+
435453
it('Path with multiple parameters and querystring: /test/123/query/456/?test=321', async function() {
436454
let _event = Object.assign({},event,{ path: '/test/123/query/456', httpMethod: 'post', queryStringParameters: { test: '321' } })
437455
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
@@ -519,6 +537,12 @@ describe('Route Tests:', function() {
519537
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"put","status":"ok","param":"123","query":"321"}', isBase64Encoded: false })
520538
}) // end it
521539

540+
it('Path with parameter and multiple querystring: /test/123/query/?test=123&test=321', async function() {
541+
let _event = Object.assign({},event,{ path: '/test/123/query', httpMethod: 'put', queryStringParameters: { test: ['123', '321'] } })
542+
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
543+
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"put","status":"ok","param":"123","query":["123","321"]}', isBase64Encoded: false })
544+
}) // end it
545+
522546
it('Path with multiple parameters and querystring: /test/123/query/456/?test=321', async function() {
523547
let _event = Object.assign({},event,{ path: '/test/123/query/456', httpMethod: 'put', queryStringParameters: { test: '321' } })
524548
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
@@ -660,6 +684,12 @@ describe('Route Tests:', function() {
660684
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"options","status":"ok","param":"123","query":"321"}', isBase64Encoded: false })
661685
}) // end it
662686

687+
it('Path with parameter and multiple querystring: /test/123/query/?test=123&test=321', async function() {
688+
let _event = Object.assign({},event,{ path: '/test/123/query', httpMethod: 'options', queryStringParameters: { test: ['123', '321'] } })
689+
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
690+
expect(result).to.deep.equal({ headers: { 'content-type': 'application/json' }, statusCode: 200, body: '{"method":"options","status":"ok","param":"123","query":["123","321"]}', isBase64Encoded: false })
691+
}) // end it
692+
663693
it('Path with multiple parameters and querystring: /test/123/query/456/?test=321', async function() {
664694
let _event = Object.assign({},event,{ path: '/test/123/query/456', httpMethod: 'options', queryStringParameters: { test: '321' } })
665695
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))

0 commit comments

Comments
 (0)