You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
640 B

'use strict';
var tape = require('tape');
var got = require('../');
var server = require('./server.js');
var s = server.createServer();
s.on('/', function (req, res) {
res.end('ok');
});
tape('setup', function (t) {
s.listen(s.port, function () {
t.end();
});
});
tape('callback mode', {timeout: 1000}, function (t) {
got.get(s.url, function (err, data) {
t.error(err);
t.equal(data, 'ok');
t.end();
});
});
tape('stream mode', {timeout: 1000}, function (t) {
got.get(s.url)
.on('data', function (data) {
t.equal(data.toString(), 'ok');
t.end();
});
});
tape('cleanup', function (t) {
s.close();
t.end();
});