2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2020-12-09 19:12:17 +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/policy';
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
module('Unit | Search | Predicate | policy', function () {
|
|
|
|
test('items are found by properties', function (assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Name: 'name-HIT',
|
|
|
|
Description: 'description',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: 'name',
|
|
|
|
Description: 'desc-HIT-ription',
|
|
|
|
},
|
|
|
|
],
|
2020-12-09 19:12:17 +00:00
|
|
|
{
|
2020-12-18 10:38:15 +00:00
|
|
|
finders: predicates,
|
|
|
|
}
|
|
|
|
).search('hit');
|
2020-12-09 19:12:17 +00:00
|
|
|
assert.equal(actual.length, 2);
|
|
|
|
});
|
2022-09-15 08:43:17 +00:00
|
|
|
test('items are not found', function (assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Name: 'name',
|
|
|
|
Description: 'description',
|
|
|
|
},
|
|
|
|
],
|
2020-12-09 19:12:17 +00:00
|
|
|
{
|
2020-12-18 10:38:15 +00:00
|
|
|
finders: predicates,
|
|
|
|
}
|
|
|
|
).search('hit');
|
2020-12-09 19:12:17 +00:00
|
|
|
assert.equal(actual.length, 0);
|
|
|
|
});
|
|
|
|
});
|