Browse Source

missing tests on options

http2
Vsevolod Strukchinsky 9 years ago
parent
commit
013a2b57f8
  1. 15
      test/arguments.js
  2. 10
      test/stream.js

15
test/arguments.js

@ -33,6 +33,17 @@ test('url is required', async t => {
} }
}); });
test('options are optional', async t => {
t.is((await got(`${s.url}/test`)).body, '/test');
});
test('options are optional', t => {
got(`${s.url}/test`, function (err, data) {
t.is(data, '/test');
t.end();
});
});
test('accepts url.parse object as first argument', async t => { test('accepts url.parse object as first argument', async t => {
t.is((await got({hostname: s.host, port: s.port, path: '/test'})).body, '/test'); t.is((await got({hostname: s.host, port: s.port, path: '/test'})).body, '/test');
}); });
@ -50,6 +61,10 @@ test('should throw with auth in url', async t => {
} }
}); });
test('accepts url.parse object as first argument', async t => {
t.is((await got({hostname: s.host, port: s.port, path: '/test'})).body, '/test');
});
test.after('cleanup', async t => { test.after('cleanup', async t => {
await s.close(); await s.close();
}); });

10
test/stream.js

@ -1,5 +1,6 @@
import test from 'ava'; import test from 'ava';
import got from '../'; import got from '../';
import intoStream from 'into-stream';
import {createServer} from './_server'; import {createServer} from './_server';
let s; let s;
@ -123,6 +124,15 @@ test('have error event', t => {
}); });
}); });
test('accepts option.body as Stream', t => {
got.stream(`${s.url}/post`, {body: intoStream(['wow'])})
.on('data', chunk => {
t.is(chunk.toString(), 'wow');
t.end();
});
});
test.after('cleanup', async t => { test.after('cleanup', async t => {
await s.close(); await s.close();
}); });

Loading…
Cancel
Save