Skip to content

Commit

Permalink
test: replace t.type with t.ok (#2720)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Feb 9, 2024
1 parent cebfdcd commit 50d691d
Show file tree
Hide file tree
Showing 28 changed files with 152 additions and 152 deletions.
2 changes: 1 addition & 1 deletion test/client-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('connect aborted after connect', (t) => {
opaque: 'asd'
}, (err, { opaque }) => {
t.equal(opaque, 'asd')
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
t.equal(client[kBusy], true)
})
Expand Down
26 changes: 13 additions & 13 deletions test/client-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ test('pipeline invalid handler return', (t) => {
body.on('error', () => {})
})
.on('error', (err) => {
t.type(err, errors.InvalidReturnValueError)
t.ok(err instanceof errors.InvalidReturnValueError)
})
.end()

Expand All @@ -353,7 +353,7 @@ test('pipeline invalid handler return', (t) => {
return {}
})
.on('error', (err) => {
t.type(err, errors.InvalidReturnValueError)
t.ok(err instanceof errors.InvalidReturnValueError)
})
.end()
})
Expand Down Expand Up @@ -409,7 +409,7 @@ test('pipeline destroy and throw handler', (t) => {
})
.end()
.on('error', (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
.on('close', () => {
t.ok(true, 'pass')
Expand Down Expand Up @@ -449,7 +449,7 @@ test('pipeline abort res', (t) => {
return body
})
.on('error', (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
.end()
})
Expand All @@ -474,7 +474,7 @@ test('pipeline abort server res', (t) => {
t.fail()
})
.on('error', (err) => {
t.type(err, errors.SocketError)
t.ok(err instanceof errors.SocketError)
})
.end()
})
Expand Down Expand Up @@ -505,7 +505,7 @@ test('pipeline abort duplex', (t) => {
}, () => {
t.fail()
}).destroy().on('error', (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
})
})
Expand Down Expand Up @@ -558,7 +558,7 @@ test('pipeline abort piped res 2', (t) => {
}, ({ body }) => {
const pt = new PassThrough()
body.on('error', (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
setImmediate(() => {
pt.destroy()
Expand All @@ -567,7 +567,7 @@ test('pipeline abort piped res 2', (t) => {
return pt
})
.on('error', (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
.end()
})
Expand Down Expand Up @@ -628,7 +628,7 @@ test('pipeline abort server res after headers', (t) => {
return data.body
})
.on('error', (err) => {
t.type(err, errors.SocketError)
t.ok(err instanceof errors.SocketError)
})
.end()
})
Expand Down Expand Up @@ -656,7 +656,7 @@ test('pipeline w/ write abort server res after headers', (t) => {
return data.body
})
.on('error', (err) => {
t.type(err, errors.SocketError)
t.ok(err instanceof errors.SocketError)
})
.resume()
.write('asd')
Expand Down Expand Up @@ -713,7 +713,7 @@ test('pipeline args validation', (t) => {
const ret = client.pipeline(null, () => {})
ret.on('error', (err) => {
t.ok(/opts/.test(err.message))
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})
})

Expand Down Expand Up @@ -866,7 +866,7 @@ test('pipeline CONNECT throw', (t) => {
}, () => {
t.fail()
}).on('error', (err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})
client.on('disconnect', () => {
t.fail()
Expand Down Expand Up @@ -1030,7 +1030,7 @@ test('pipeline abort after headers', (t) => {
})
.end()
.on('error', (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
})
})
4 changes: 2 additions & 2 deletions test/client-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test('request abort before headers', (t) => {
method: 'GET',
signal
}, (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
t.equal(signal.listenerCount('abort'), 0)
})
t.equal(signal.listenerCount('abort'), 1)
Expand All @@ -127,7 +127,7 @@ test('request abort before headers', (t) => {
method: 'GET',
signal
}, (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
t.equal(signal.listenerCount('abort'), 0)
})
t.equal(signal.listenerCount('abort'), 2)
Expand Down
20 changes: 10 additions & 10 deletions test/client-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,17 @@ test('stream args validation', (t) => {
path: '/',
method: 'GET'
}, null, (err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})

client.stream(null, null, (err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})

try {
client.stream(null, null, 'asd')
} catch (err) {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
}
})

Expand All @@ -285,11 +285,11 @@ test('stream args validation promise', (t) => {
path: '/',
method: 'GET'
}, null).catch((err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})

client.stream(null, null).catch((err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})
})

Expand Down Expand Up @@ -337,7 +337,7 @@ test('stream server side destroy', (t) => {
}, () => {
t.fail()
}, (err) => {
t.type(err, errors.SocketError)
t.ok(err instanceof errors.SocketError)
})
})
})
Expand All @@ -360,7 +360,7 @@ test('stream invalid return', (t) => {
}, () => {
return {}
}, (err) => {
t.type(err, errors.InvalidReturnValueError)
t.ok(err instanceof errors.InvalidReturnValueError)
})
})
})
Expand Down Expand Up @@ -413,7 +413,7 @@ test('stream factory abort', (t) => {
return new PassThrough()
}, (err) => {
t.equal(signal.listenerCount('abort'), 0)
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
t.equal(signal.listenerCount('abort'), 1)
})
Expand Down Expand Up @@ -475,7 +475,7 @@ test('stream CONNECT throw', (t) => {
method: 'CONNECT'
}, () => {
}, (err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})
})
})
Expand Down Expand Up @@ -528,7 +528,7 @@ test('stream abort before dispatch', (t) => {
}, () => {
return pt
}, (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
signal.emit('abort')
})
Expand Down
6 changes: 3 additions & 3 deletions test/client-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test('refresh timeout on pause', (t) => {

},
onError (err) {
t.type(err, errors.BodyTimeoutError)
t.ok(err instanceof errors.BodyTimeoutError)
}
})
})
Expand Down Expand Up @@ -96,7 +96,7 @@ test('start headers timeout after request body', (t) => {
},
onError (err) {
t.equal(body.readableEnded, true)
t.type(err, errors.HeadersTimeoutError)
t.ok(err instanceof errors.HeadersTimeoutError)
}
})
})
Expand Down Expand Up @@ -153,7 +153,7 @@ test('start headers timeout after async iterator request body', (t) => {

},
onError (err) {
t.type(err, errors.HeadersTimeoutError)
t.ok(err instanceof errors.HeadersTimeoutError)
}
})
})
Expand Down
16 changes: 8 additions & 8 deletions test/client-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,23 @@ test('upgrade invalid opts', (t) => {
const client = new Client('http://localhost:5432')

client.upgrade(null, err => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid opts')
})

try {
client.upgrade(null, null)
t.fail()
} catch (err) {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid opts')
}

try {
client.upgrade({ path: '/' }, null)
t.fail()
} catch (err) {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid callback')
}
})
Expand Down Expand Up @@ -308,7 +308,7 @@ test('upgrade aborted', (t) => {
opaque: 'asd'
}, (err, { opaque }) => {
t.equal(opaque, 'asd')
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
t.equal(signal.listenerCount('abort'), 0)
})
t.equal(client[kBusy], true)
Expand Down Expand Up @@ -351,7 +351,7 @@ test('basic aborted after res', (t) => {
protocol: 'Websocket',
signal
}, (err) => {
t.type(err, errors.RequestAbortedError)
t.ok(err instanceof errors.RequestAbortedError)
})
})
})
Expand Down Expand Up @@ -408,7 +408,7 @@ test('upgrade disconnect', (t) => {

client.on('disconnect', (origin, [self], error) => {
t.equal(client, self)
t.type(error, Error)
t.ok(error instanceof Error)
})

client
Expand All @@ -417,7 +417,7 @@ test('upgrade disconnect', (t) => {
t.fail()
})
.catch(error => {
t.type(error, Error)
t.ok(error instanceof Error)
})
})
})
Expand Down Expand Up @@ -446,7 +446,7 @@ test('upgrade invalid signal', (t) => {
opaque: 'asd'
}, (err, { opaque }) => {
t.equal(opaque, 'asd')
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})
})
})
6 changes: 3 additions & 3 deletions test/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,13 +1412,13 @@ test('request args validation', (t) => {
const client = new Client('http://localhost:5000')

client.request(null, (err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})

try {
client.request(null, 'asd')
} catch (err) {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
}
})

Expand All @@ -1428,7 +1428,7 @@ test('request args validation promise', (t) => {
const client = new Client('http://localhost:5000')

client.request(null).catch((err) => {
t.type(err, errors.InvalidArgumentError)
t.ok(err instanceof errors.InvalidArgumentError)
})
})

Expand Down

0 comments on commit 50d691d

Please sign in to comment.