From ac999d3b37310cde1805e0a7051a5f7795add463 Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Thu, 19 Jan 2017 15:36:32 +0900 Subject: [PATCH] test: add dgram.Socket.prototype.bind's test bind: https://github.com/nodejs/node/blob/master/lib/dgram.js#L140 --- test/parallel/test-dgram-bind.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-dgram-bind.js b/test/parallel/test-dgram-bind.js index 882f2e87bdd7ee..f4624358a4fab4 100644 --- a/test/parallel/test-dgram-bind.js +++ b/test/parallel/test-dgram-bind.js @@ -1,13 +1,17 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); -socket.on('listening', function() { +socket.on('listening', common.mustCall(() => { + assert.throws(() => { + socket.bind(); + }, /^Error: Socket is already bound$/); + socket.close(); -}); +})); const result = socket.bind(); // should not throw