node/test/parallel/test-dgram-sendto.js
Mithun Sasidharan 20a8e83e44
test: replace assert.throws w/ common.expectsError
PR-URL: https://github.com/nodejs/node/pull/17494
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-12-08 13:34:54 -05:00

48 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../common');
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');
const errorMessageOffset =
/^The "offset" argument must be of type number$/;
common.expectsError(() => {
socket.sendto();
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: errorMessageOffset
});
common.expectsError(() => {
socket.sendto('buffer', 1, 'offset', 'port', 'address', 'cb');
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "length" argument must be of type number$/
});
common.expectsError(() => {
socket.sendto('buffer', 'offset', 1, 'port', 'address', 'cb');
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: errorMessageOffset
});
common.expectsError(() => {
socket.sendto('buffer', 1, 1, 10, false, 'cb');
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "address" argument must be of type string$/
});
common.expectsError(() => {
socket.sendto('buffer', 1, 1, false, 'address', 'cb');
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "port" argument must be of type number$/
});