• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3if (!common.hasCrypto)
4  common.skip('missing crypto');
5
6const assert = require('assert');
7const tls = require('tls');
8
9['foobar', 1, {}, []].forEach(function connectThrows(input) {
10  const opts = {
11    host: 'localhost',
12    port: common.PORT,
13    lookup: input
14  };
15
16  assert.throws(() => {
17    tls.connect(opts);
18  }, {
19    code: 'ERR_INVALID_ARG_TYPE',
20    name: 'TypeError'
21  });
22});
23
24connectDoesNotThrow(common.mustCall(() => {}));
25
26function connectDoesNotThrow(input) {
27  const opts = {
28    host: 'localhost',
29    port: common.PORT,
30    lookup: input
31  };
32
33  tls.connect(opts);
34}
35