@incdevco/framework
Version:
node.js lambda framework
64 lines (49 loc) • 2.55 kB
JavaScript
var Expect = require('chai').expect;
var Request = require('./index');
describe('api/request', function () {
it('should put querystring in query if object', function () {
var config = {
querystring: {
key: 'value'
}
};
var request = new Request(config);
Expect(request.query).to.deep.equal(config.querystring, 'request.query');
});
it('should have correct query params', function() {
var config = {
"body": "Called=%2B13853931363&ToState=UT&CallerCountry=US&Direction=inbound&CallerState=UT&ToZip=&CallSid=CA93ff1d0dbf27a655b0939e7ef4881b7d&To=%2B13853931363&CallerZip=&ToCountry=US&ApiVersion=2010-04-01&CalledZip=&CalledCity=SALT+LAKE+CITY&CallStatus=completed&From=%2B13852988363&AccountSid=AC2bc7a6b7beb9b4a5de7227bcc5825629&CalledCountry=US&CallerCity=SALT+LAKE+CITY&Caller=%2B13852988363&FromCountry=US&ToCity=SALT+LAKE+CITY&FromCity=SALT+LAKE+CITY&CalledState=UT&FromZip=&FromState=UT",
"querystring": {
"attempts": "2"
},
"headers": {
"Cache-Control": "max-age=259200",
"CloudFront-Forwarded-Proto": "https",
"CloudFront-Is-Desktop-Viewer": "true",
"CloudFront-Is-Mobile-Viewer": "false",
"CloudFront-Is-SmartTV-Viewer": "false",
"CloudFront-Is-Tablet-Viewer": "false",
"CloudFront-Viewer-Country": "US",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Host": "web-hooks.development.cn.incdev.co",
"Referer": "https://web-hooks.development.cn.incdev.co/twilio/calls/input?attempts=1",
"User-Agent": "TwilioProxy/1.1",
"Via": "1.1 eb53c6a0d1be72f83a75c1af82e646b7.cloudfront.net (CloudFront)",
"X-Amz-Cf-Id": "zpV97JhMXr6I62eSk-SeKoLh28MXGCbO459JHPMjztrl3MlIgvK5iw==",
"X-Amzn-Trace-Id": "Root=1-599cb4dc-64abc464010106b046dacfcb",
"X-Forwarded-For": "34.230.62.101, 54.240.144.7",
"X-Forwarded-Port": "443",
"X-Forwarded-Proto": "https",
"X-Twilio-Signature": "xA1rIeI+02If4t6enbHl46dq8CU="
},
"method": "POST",
"requestId": "16ae1cff-878c-11e7-912b-3b044446d700",
"originalPath": "/twilio/calls/input",
"path": "/twilio/calls/input",
"sourceIp": "",
"stage": "development"
};
var request = new Request(config);
Expect(request.query.attempts).to.equal('2', 'request.query.attempts');
});
});