Skip to content

Commit

Permalink
fix node 19.1.0 port validation test (#4427)
Browse files Browse the repository at this point in the history
* fix node 19.1.0 port validation test

* Apply suggestions from code review

* check for ERR_SOCKET_BAD_PORT
  • Loading branch information
Uzlopak committed Nov 18, 2022
1 parent 3767bc2 commit 36d84bc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions test/server.test.js
Expand Up @@ -36,19 +36,18 @@ test('listen should accept stringified number port', t => {

test('listen should reject string port', async (t) => {
t.plan(2)

const fastify = Fastify()
t.teardown(fastify.close.bind(fastify))

try {
await fastify.listen({ port: 'hello-world' })
} catch (error) {
t.same(error.message, 'options.port should be >= 0 and < 65536. Received hello-world.')
t.equal(error.code, 'ERR_SOCKET_BAD_PORT')
}

try {
await fastify.listen({ port: '1234hello' })
} catch (error) {
t.same(error.message, 'options.port should be >= 0 and < 65536. Received 1234hello.')
t.equal(error.code, 'ERR_SOCKET_BAD_PORT')
}
})

0 comments on commit 36d84bc

Please sign in to comment.