summaryrefslogtreecommitdiffstats
path: root/test/connect-abort.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/connect-abort.js')
-rw-r--r--test/connect-abort.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/connect-abort.js b/test/connect-abort.js
new file mode 100644
index 0000000..6eb3624
--- /dev/null
+++ b/test/connect-abort.js
@@ -0,0 +1,28 @@
+'use strict'
+
+const { test } = require('tap')
+const { Client } = require('..')
+const { PassThrough } = require('stream')
+
+test(t => {
+ t.plan(2)
+
+ const client = new Client('http://localhost:1234', {
+ connect: (_, cb) => {
+ client.destroy()
+ cb(null, new PassThrough({
+ destroy (err, cb) {
+ t.same(err?.name, 'ClientDestroyedError')
+ cb(null)
+ }
+ }))
+ }
+ })
+
+ client.request({
+ path: '/',
+ method: 'GET'
+ }, (err, data) => {
+ t.same(err?.name, 'ClientDestroyedError')
+ })
+})