mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-22 12:01:25 +00:00
27 lines
604 B
JavaScript
27 lines
604 B
JavaScript
/*
|
|
* test for rule replaceOption rule
|
|
*
|
|
*/
|
|
const util = require('../../lib/util');
|
|
|
|
describe('utils', () => {
|
|
it('should get some free ports', done => {
|
|
const count = 100;
|
|
const tasks = [];
|
|
for (let i = 1; i <= count; i++) {
|
|
tasks.push(util.getFreePort());
|
|
}
|
|
Promise.all(tasks)
|
|
.then((results) => {
|
|
// ensure ports are unique
|
|
const portMap = {};
|
|
results.map((portNumber) => {
|
|
portMap[portNumber] = true;
|
|
});
|
|
expect(Object.keys(portMap).length).toEqual(count);
|
|
done();
|
|
})
|
|
.catch(done.fail);
|
|
});
|
|
});
|