Skip to content

Commit

Permalink
chore: migrate a batch of tests to node test runner (nodejs#2742)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored and crysmags committed Feb 21, 2024
1 parent 9f3fcfd commit 6c0f65f
Show file tree
Hide file tree
Showing 11 changed files with 446 additions and 347 deletions.
15 changes: 9 additions & 6 deletions test/client-errors.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
'use strict'

const { test } = require('tap')
const { tspl } = require('@matteo.collina/tspl')
const { test, after } = require('node:test')
const { Client } = require('..')
const net = require('node:net')

// TODO: move to test/node-test/client-connect.js
test('parser error', (t) => {
t.plan(2)
test('parser error', async (t) => {
t = tspl(t, { plan: 2 })

const server = net.createServer()
server.once('connection', (socket) => {
socket.write('asd\n\r213123')
})
t.teardown(server.close.bind(server))
after(() => server.close())

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.teardown(client.destroy.bind(client))
after(() => client.destroy())

client.request({ path: '/', method: 'GET' }, (err) => {
t.ok(err)
client.close((err) => {
t.error(err)
t.ifError(err)
})
})
})

await t.completed
})
Loading

0 comments on commit 6c0f65f

Please sign in to comment.