mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
add test for order of returned items
This commit is contained in:
parent
9df854e62d
commit
89f61ae2e4
1 changed files with 26 additions and 0 deletions
|
@ -130,6 +130,32 @@ define(function (require) {
|
|||
expect($typeaheadScope.items).to.be.an('array');
|
||||
expect($typeaheadScope.items.length).to.be(typeaheadItems.length);
|
||||
});
|
||||
|
||||
it('should order fitlered results', function () {
|
||||
var entries = ['ac/dc', 'anthrax', 'abba', 'phantogram', 'skrillex'];
|
||||
var allEntries = typeaheadItems.concat(entries);
|
||||
var startMatches = allEntries.filter(function (item) {
|
||||
return /^a/.test(item);
|
||||
});
|
||||
typeaheadCtrl.history.add.returns(allEntries);
|
||||
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
$typeaheadScope.inputModel.$setViewValue(entries[i]);
|
||||
typeaheadCtrl.persistEntry();
|
||||
}
|
||||
|
||||
typeaheadCtrl.filterItemsByQuery('a');
|
||||
|
||||
expect($typeaheadScope.filteredItems).to.contain('phantogram');
|
||||
var nonStarterIndex = $typeaheadScope.filteredItems.indexOf('phantogram');
|
||||
|
||||
startMatches.forEach(function (item) {
|
||||
expect($typeaheadScope.filteredItems).to.contain(item);
|
||||
expect($typeaheadScope.filteredItems.indexOf(item)).to.be.below(nonStarterIndex);
|
||||
});
|
||||
|
||||
expect($typeaheadScope.filteredItems).not.to.contain('skrillex');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue