Skip to content

Commit

Permalink
Fix build (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobenna authored and sindresorhus committed Nov 1, 2019
1 parent 421d049 commit c2123a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
"devDependencies": {
"@sindresorhus/tsconfig": "^0.3.0",
"@types/node": "^11.13.6",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"ava": "^1.4.1",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"ava": "^2.1.0",
"coveralls": "^3.0.3",
"del-cli": "^1.1.0",
"eslint-config-xo-typescript": "^0.9.0",
"eslint-config-xo-typescript": "^0.15.0",
"nyc": "^14.0.0",
"p-event": "^4.1.0",
"ts-node": "^8.1.0",
Expand Down
18 changes: 9 additions & 9 deletions test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {AddressInfo} from 'net';
import http, {ClientRequest, IncomingMessage} from 'http';
import EventEmitter from 'events';
import http, {ClientRequest, IncomingMessage, RequestOptions} from 'http';
import https from 'https';
import {AddressInfo} from 'net';
import {parse as parseUrl, URL} from 'url'; // eslint-disable-line node/no-deprecated-api
import util from 'util';
import {URL, parse as parseUrl} from 'url'; // eslint-disable-line node/no-deprecated-api
import EventEmitter from 'events';
import test from 'ava';
import pEvent from 'p-event';
import test from 'ava';
import timer, {Timings} from './source';

let server: http.Server & {
Expand Down Expand Up @@ -108,14 +108,14 @@ test('sets `total` on request error', async t => {
const request = http.get({
...parseUrl(server.url!),
timeout: 1
});
} as RequestOptions);
request.on('timeout', () => {
request.abort();
});

const timings = timer(request);

const err = await pEvent(request, 'error');
const err: Error = await pEvent(request, 'error');
t.is(err.message, 'socket hang up');

t.is(typeof timings.error, 'number');
Expand All @@ -138,12 +138,12 @@ test('sets `total` on response error', async t => {
t.is(timings.phases.total, timings.error! - timings.start);
});

test('doesn\'t throw when someone used `.prependOnceListener()`', async t => {
test('doesn\'t throw when someone used `.prependOnceListener()`', t => {
const emitter = new EventEmitter();
timer(emitter as ClientRequest);
emitter.prependOnceListener('error', () => {});

await t.notThrows(() => emitter.emit('error', new Error(error)));
t.notThrows(() => emitter.emit('error', new Error(error)));
});

test('sensible timings', async t => {
Expand Down

0 comments on commit c2123a1

Please sign in to comment.