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.
 

36 lines
644 B

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