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/acl';
|
|
|
|
|
2020-12-01 15:45:09 +00:00
|
|
|
module('Unit | Search | Predicate | acl', function() {
|
|
|
|
test('items are found by properties', function(assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
ID: 'HIT-id',
|
|
|
|
Name: 'name',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: 'id',
|
|
|
|
Name: 'name',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: 'id',
|
|
|
|
Name: 'name-HIT',
|
|
|
|
},
|
|
|
|
],
|
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, 2);
|
|
|
|
});
|
|
|
|
test('items are not found', function(assert) {
|
2020-12-18 10:38:15 +00:00
|
|
|
const actual = new ExactSearch(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
ID: 'id',
|
|
|
|
Name: 'name',
|
|
|
|
},
|
|
|
|
],
|
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);
|
|
|
|
});
|
|
|
|
});
|