Skip to content

Commit ac999d3

Browse files
committed
test: add dgram.Socket.prototype.bind's test
bind: https://github.com/nodejs/node/blob/master/lib/dgram.js#L140
1 parent c4b4611 commit ac999d3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/parallel/test-dgram-bind.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const assert = require('assert');
44
const dgram = require('dgram');
55

66
const socket = dgram.createSocket('udp4');
77

8-
socket.on('listening', function() {
8+
socket.on('listening', common.mustCall(() => {
9+
assert.throws(() => {
10+
socket.bind();
11+
}, /^Error: Socket is already bound$/);
12+
913
socket.close();
10-
});
14+
}));
1115

1216
const result = socket.bind(); // should not throw
1317

0 commit comments

Comments
 (0)