Skip to content

Commit

Permalink
test: invalid callback for client connect/upgrade (nodejs#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored and crysmags committed Feb 27, 2024
1 parent 56068a2 commit 31ee4b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion test/client-connect.js
Expand Up @@ -114,18 +114,29 @@ test('connect error', (t) => {
})

test('connect invalid opts', (t) => {
t.plan(2)
t.plan(6)

const client = new Client('http://localhost:5432')

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

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

try {
client.connect({ path: '/' }, null)
t.fail()
} catch (err) {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid callback')
}
})

Expand Down
13 changes: 12 additions & 1 deletion test/client-upgrade.js
Expand Up @@ -146,18 +146,29 @@ test('upgrade error', (t) => {
})

test('upgrade invalid opts', (t) => {
t.plan(2)
t.plan(6)

const client = new Client('http://localhost:5432')

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

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

try {
client.upgrade({ path: '/' }, null)
t.fail()
} catch (err) {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid callback')
}
})

Expand Down

0 comments on commit 31ee4b7

Please sign in to comment.