UNPKG

fluentnode

Version:

Fluent apis for node (based on the concepts used in C#'s FluentSharp

59 lines (54 loc) 1.69 kB
// Generated by CoffeeScript 1.12.7 (function() { var http; require('../../src/fluentnode'); http = require('http'); describe('| node-native | http.POST', function() { var req_Data, server, test_Data, test_Ip, test_Port, url; test_Port = 45566 + Math.floor((Math.random() * 100) + 1); test_Ip = '127.0.0.1'; test_Data = 'hello from web'; url = "http://" + test_Ip + ":" + test_Port; server = null; req_Data = "aaa=bbb"; before(function(done) { server = http.createServer(null); return server.listen_OnPort_Saying(test_Port, test_Data, (function(_this) { return function() { return done(); }; })(this)); }); after(function(done) { return server.close_And_Destroy_Sockets(function() { return done(); }); }); it('http_POST', function(done) { var req; server.respond_With_Request_Headers(); req = url.http_POST(req_Data, function(error, data, res) { assert_Is_Null(error); data.json_Parse().assert_Is({ 'host': test_Ip + ":" + test_Port, 'connection': 'close', 'content-length': '0' }); res.headers['content-type'].assert_Is('application/json'); return done(); }); return req.method.assert_Is('POST'); }); return it('POST', function(done) { server.respond_With_Request_Headers(); return url.POST(req_Data, function(data) { data.json_Parse().assert_Is({ 'host': test_Ip + ":" + test_Port, 'connection': 'close', 'content-length': '0' }); return done(); }); }); }); }).call(this);