Skip to content

Commit

Permalink
test: invalid callback for client connect/upgrade (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed May 10, 2021
1 parent 091a4a9 commit 4818569
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 4818569

Please sign in to comment.