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/kv';
|
|
|
|
|
2020-12-01 15:45:09 +00:00
|
|
|
module('Unit | Search | Predicate | kv', function() {
|
|
|
|
test('items are found by properties', function(assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Key: 'HIT-here',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Key: 'folder-HIT/',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Key: 'excluded',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Key: 'really/long/path/HIT-here',
|
|
|
|
},
|
|
|
|
],
|
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, 3);
|
|
|
|
});
|
|
|
|
test('items are not found', function(assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
Key: 'key',
|
|
|
|
},
|
|
|
|
],
|
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);
|
|
|
|
});
|
|
|
|
});
|