mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 05:23:04 +00:00
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
104 lines
2.1 KiB
JavaScript
104 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import ExactSearch from 'consul-ui/utils/search/exact';
|
|
import predicates from 'consul-ui/search/predicates/service';
|
|
|
|
module('Unit | Search | Predicate | service', function () {
|
|
test('items are found by properties', function (assert) {
|
|
const actual = new ExactSearch(
|
|
[
|
|
{
|
|
Name: 'name-HIT',
|
|
Tags: [],
|
|
},
|
|
{
|
|
Name: 'name',
|
|
Tags: ['tag', 'tag-withHiT'],
|
|
},
|
|
],
|
|
{
|
|
finders: predicates,
|
|
}
|
|
).search('hit');
|
|
assert.equal(actual.length, 2);
|
|
});
|
|
test('items are not found', function (assert) {
|
|
const actual = new ExactSearch(
|
|
[
|
|
{
|
|
Name: 'name',
|
|
},
|
|
{
|
|
Name: 'name',
|
|
Tags: ['one', 'two'],
|
|
},
|
|
],
|
|
{
|
|
finders: predicates,
|
|
}
|
|
).search('hit');
|
|
assert.equal(actual.length, 0);
|
|
});
|
|
test('tags can be empty', function (assert) {
|
|
const actual = new ExactSearch(
|
|
[
|
|
{
|
|
Name: 'name',
|
|
},
|
|
{
|
|
Name: 'name',
|
|
Tags: null,
|
|
},
|
|
{
|
|
Name: 'name',
|
|
Tags: [],
|
|
},
|
|
],
|
|
{
|
|
finders: predicates,
|
|
}
|
|
).search('hit');
|
|
assert.equal(actual.length, 0);
|
|
});
|
|
test('items can be found by Partition', function (assert) {
|
|
const search = new ExactSearch(
|
|
[
|
|
{
|
|
Name: 'name-a',
|
|
Partition: 'default',
|
|
},
|
|
{
|
|
Name: 'name-b',
|
|
Partition: 'lorem-ipsum',
|
|
},
|
|
],
|
|
{
|
|
finders: predicates,
|
|
}
|
|
);
|
|
|
|
assert.deepEqual(
|
|
search.search('').map((i) => i.Name),
|
|
['name-a', 'name-b'],
|
|
'both items included in search'
|
|
);
|
|
|
|
assert.deepEqual(
|
|
search.search('def').map((i) => i.Name),
|
|
['name-a'],
|
|
'only item from default partition is included'
|
|
);
|
|
|
|
assert.deepEqual(
|
|
search.search('tomster').map((i) => i.Name),
|
|
[],
|
|
'no item included when no Partition matches'
|
|
);
|
|
});
|
|
});
|