0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/disabled/test-cat.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2009-10-29 23:59:35 +01:00
process.mixin(require("../common.js"));
2009-09-28 12:36:36 +02:00
http = require("/http.js");
2009-06-21 16:40:08 +02:00
puts("hello world");
2009-06-21 16:40:08 +02:00
var body = "exports.A = function() { return 'A';}";
2009-09-28 12:36:36 +02:00
var server = http.createServer(function (req, res) {
puts("req?");
res.sendHeader(200, {
"Content-Length": body.length,
"Content-Type": "text/plain"
});
2009-06-21 16:40:08 +02:00
res.sendBody(body);
res.finish();
});
server.listen(PORT);
2009-06-28 19:05:58 +02:00
var errors = 0;
var successes = 0;
2009-10-29 23:59:35 +01:00
var promise = process.cat("http://localhost:"+PORT, "utf8");
2009-06-28 19:05:58 +02:00
2009-08-26 18:22:00 +02:00
promise.addCallback(function (content) {
assert.equal(body, content);
2009-08-26 18:22:00 +02:00
server.close();
successes += 1;
});
2009-06-28 19:05:58 +02:00
2009-08-26 18:22:00 +02:00
promise.addErrback(function () {
errors += 1;
});
2009-10-29 23:59:35 +01:00
var dirname = process.path.dirname(__filename);
var fixtures = process.path.join(dirname, "fixtures");
var x = process.path.join(fixtures, "x.txt");
2009-08-26 18:22:00 +02:00
2009-10-29 23:59:35 +01:00
promise = process.cat(x, "utf8");
2009-08-26 18:22:00 +02:00
promise.addCallback(function (content) {
assert.equal("xyz", content.replace(/[\r\n]/, ''));
2009-08-26 18:22:00 +02:00
successes += 1;
});
promise.addErrback(function () {
errors += 1;
});
2009-06-28 19:05:58 +02:00
process.addListener("exit", function () {
assert.equal(2, successes);
assert.equal(0, errors);
});