Files
elasticsearch-js/test/unit/selectors.test.js
2018-11-05 19:22:36 +01:00

24 lines
528 B
JavaScript

'use strict'
const { test } = require('tap')
const { roundRobinSelector, randomSelector } = require('../../lib/ConnectionPool').internals
test('RoundRobinSelector', t => {
const selector = roundRobinSelector()
const arr = [0, 1, 2, 3, 4, 5]
t.plan(arr.length + 1)
for (var i = 0; i <= arr.length; i++) {
t.strictEqual(
selector(arr),
i === arr.length ? arr[0] : arr[i]
)
}
})
test('RandomSelector', t => {
t.plan(1)
const arr = [0, 1, 2, 3, 4, 5]
t.type(randomSelector(arr), 'number')
})