diff options
Diffstat (limited to 'node_modules/selenium-webdriver/test/net')
-rw-r--r-- | node_modules/selenium-webdriver/test/net/index_test.js | 60 | ||||
-rw-r--r-- | node_modules/selenium-webdriver/test/net/portprober_test.js | 128 |
2 files changed, 0 insertions, 188 deletions
diff --git a/node_modules/selenium-webdriver/test/net/index_test.js b/node_modules/selenium-webdriver/test/net/index_test.js deleted file mode 100644 index 88c52c063..000000000 --- a/node_modules/selenium-webdriver/test/net/index_test.js +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -'use strict'; - -var assert = require('assert'); - -var net = require('../../net'); - -describe('net.splitHostAndPort', function() { - it('hostname with no port', function() { - assert.deepEqual( - net.splitHostAndPort('www.example.com'), - {host: 'www.example.com', port: null}); - }); - - it('hostname with port', function() { - assert.deepEqual( - net.splitHostAndPort('www.example.com:80'), - {host: 'www.example.com', port: 80}); - }); - - it('IPv4 with no port', function() { - assert.deepEqual( - net.splitHostAndPort('127.0.0.1'), - {host: '127.0.0.1', port: null}); - }); - - it('IPv4 with port', function() { - assert.deepEqual( - net.splitHostAndPort('127.0.0.1:1234'), - {host: '127.0.0.1', port: 1234}); - }); - - it('IPv6 with no port', function() { - assert.deepEqual( - net.splitHostAndPort('1234:0:1000:5768:1234:5678:90'), - {host: '1234:0:1000:5768:1234:5678:90', port: null}); - }); - - it('IPv6 with port', function() { - assert.deepEqual( - net.splitHostAndPort('[1234:0:1000:5768:1234:5678:90]:1234'), - {host: '1234:0:1000:5768:1234:5678:90', port: 1234}); - }); -}); diff --git a/node_modules/selenium-webdriver/test/net/portprober_test.js b/node_modules/selenium-webdriver/test/net/portprober_test.js deleted file mode 100644 index 668c4ae0e..000000000 --- a/node_modules/selenium-webdriver/test/net/portprober_test.js +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -'use strict'; - -const assert = require('assert'); -const net = require('net'); - -const portprober = require('../../net/portprober'); - -describe('isFree', function() { - - var server; - - beforeEach(function() { - server = net.createServer(function(){}); - }) - - afterEach(function(done) { - if (!server) return done(); - server.close(function() { - done(); - }); - }); - - it('should work for INADDR_ANY', function(done) { - server.listen(0, function() { - var port = server.address().port; - assertPortNotfree(port).then(function() { - return new Promise(resolve => { - server.close(function() { - server = null; - resolve(assertPortIsFree(port)); - }); - }); - }).then(function() { done(); }, done); - }); - }); - - it('should work for a specific host', function(done) { - var host = '127.0.0.1'; - server.listen(0, host, function() { - var port = server.address().port; - assertPortNotfree(port, host).then(function() { - return new Promise(resolve => { - server.close(function() { - server = null; - resolve(assertPortIsFree(port, host)); - }); - }); - }).then(function() { done(); }, done); - }); - }); -}); - -describe('findFreePort', function() { - var server; - - beforeEach(function() { - server = net.createServer(function(){}); - }) - - afterEach(function(done) { - if (!server) return done(); - server.close(function() { - done(); - }); - }); - - it('should work for INADDR_ANY', function(done) { - portprober.findFreePort().then(function(port) { - server.listen(port, function() { - assertPortNotfree(port).then(function() { - return new Promise(resolve => { - server.close(function() { - server = null; - resolve(assertPortIsFree(port)); - }); - }); - }).then(function() { done(); }, done); - }); - }); - }); - - it('should work for a specific host', function(done) { - var host = '127.0.0.1'; - portprober.findFreePort(host).then(function(port) { - server.listen(port, host, function() { - assertPortNotfree(port, host).then(function() { - return new Promise(resolve => { - server.close(function() { - server = null; - resolve(assertPortIsFree(port, host)); - }); - }); - }).then(function() { done(); }, done); - }); - }); - }); -}); - - -function assertPortIsFree(port, opt_host) { - return portprober.isFree(port, opt_host).then(function(free) { - assert.ok(free, 'port should be free'); - }); -} - - -function assertPortNotfree(port, opt_host) { - return portprober.isFree(port, opt_host).then(function(free) { - assert.ok(!free, 'port should is not free'); - }); -} |