1 var server = require('./server')
2 , assert = require('assert')
3 , request = require('../index')
5 var s = server.createSSLServer();
9 { resp : server.createGetResponse("TESTING!")
10 , expectBody: "TESTING!"
13 { resp : server.createChunkResponse(
26 { resp : server.createGetResponse('{"test":true}', 'application/json')
28 , expectBody: {"test":true}
31 { resp : server.createPostValidator("PUTTINGDATA")
33 , body : "PUTTINGDATA"
36 { resp : server.createPostValidator("PUTTINGDATA")
38 , body : new Buffer("PUTTINGDATA")
41 { resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
46 { resp: server.createPostValidator(
47 '--__BOUNDARY__\r\n' +
48 'content-type: text/html\r\n' +
50 '<html><body>Oh hi.</body></html>' +
51 '\r\n--__BOUNDARY__\r\n\r\n' +
53 '\r\n--__BOUNDARY__--'
57 [ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
63 s.listen(s.port, function () {
70 s.on('/'+i, test.resp)
71 test.uri = s.url + '/' + i
72 test.rejectUnauthorized = false
73 request(test, function (err, resp, body) {
75 if (test.expectBody) {
76 assert.deepEqual(test.expectBody, body)
78 counter = counter - 1;
80 console.log(Object.keys(tests).length+" tests passed.")