2020-12-01 15:45:09 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
2020-12-18 10:38:15 +00:00
|
|
|
import ExactSearch from 'consul-ui/utils/search/exact';
|
|
|
|
import predicates from 'consul-ui/search/predicates/node';
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
module('Unit | Search | Predicate | node', function () {
|
|
|
|
test('items are found by name', function (assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Node: 'node-HIT',
|
|
|
|
Address: '10.0.0.0',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Node: 'node',
|
|
|
|
Address: '10.0.0.0',
|
|
|
|
},
|
|
|
|
],
|
2020-12-01 15:45:09 +00:00
|
|
|
{
|
2020-12-18 10:38:15 +00:00
|
|
|
finders: predicates,
|
|
|
|
}
|
|
|
|
).search('hit');
|
2020-12-01 15:45:09 +00:00
|
|
|
assert.equal(actual.length, 1);
|
|
|
|
});
|
2022-09-15 08:43:17 +00:00
|
|
|
test('items are found by IP address', function (assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Node: 'node-HIT',
|
|
|
|
Address: '10.0.0.0',
|
|
|
|
},
|
|
|
|
],
|
2020-12-01 15:45:09 +00:00
|
|
|
{
|
2020-12-18 10:38:15 +00:00
|
|
|
finders: predicates,
|
|
|
|
}
|
|
|
|
).search('10');
|
2020-12-01 15:45:09 +00:00
|
|
|
assert.equal(actual.length, 1);
|
|
|
|
});
|
2022-09-15 08:43:17 +00:00
|
|
|
test('items are not found by name', function (assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Node: 'name',
|
|
|
|
Address: '10.0.0.0',
|
|
|
|
},
|
|
|
|
],
|
2020-12-01 15:45:09 +00:00
|
|
|
{
|
2020-12-18 10:38:15 +00:00
|
|
|
finders: predicates,
|
|
|
|
}
|
|
|
|
).search('hit');
|
2020-12-01 15:45:09 +00:00
|
|
|
assert.equal(actual.length, 0);
|
|
|
|
});
|
2022-09-15 08:43:17 +00:00
|
|
|
test('items are not found by IP address', function (assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Node: 'name',
|
|
|
|
Address: '10.0.0.0',
|
|
|
|
},
|
|
|
|
],
|
2020-12-01 15:45:09 +00:00
|
|
|
{
|
2020-12-18 10:38:15 +00:00
|
|
|
finders: predicates,
|
|
|
|
}
|
|
|
|
).search('9');
|
2020-12-01 15:45:09 +00:00
|
|
|
assert.equal(actual.length, 0);
|
|
|
|
});
|
|
|
|
});
|