5dbfbf0049
Moves search things around to match an interface that can be switched in and out of fuzzy searching using fuse.js. We add both fuzzy searching and regex based searching to the codebase here, but it is not yet compiled in.
40 lines
907 B
JavaScript
40 lines
907 B
JavaScript
import { module, test } from 'qunit';
|
|
|
|
import ExactSearch from 'consul-ui/utils/search/exact';
|
|
import predicates from 'consul-ui/search/predicates/policy';
|
|
|
|
module('Unit | Search | Predicate | policy', function() {
|
|
test('items are found by properties', function(assert) {
|
|
const actual = new ExactSearch(
|
|
[
|
|
{
|
|
Name: 'name-HIT',
|
|
Description: 'description',
|
|
},
|
|
{
|
|
Name: 'name',
|
|
Description: 'desc-HIT-ription',
|
|
},
|
|
],
|
|
{
|
|
finders: predicates,
|
|
}
|
|
).search('hit');
|
|
assert.equal(actual.length, 2);
|
|
});
|
|
test('items are not found', function(assert) {
|
|
const actual = new ExactSearch(
|
|
[
|
|
{
|
|
Name: 'name',
|
|
Description: 'description',
|
|
},
|
|
],
|
|
{
|
|
finders: predicates,
|
|
}
|
|
).search('hit');
|
|
assert.equal(actual.length, 0);
|
|
});
|
|
});
|