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';
|
|
|
|
|
2020-12-09 19:12: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);
|
|
|
|
});
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|