Skip to content

Commit

Permalink
test(search): verify we prioritize exact match
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Nov 4, 2024
1 parent 2503808 commit ff2c23a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/spec/features/search/searchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,36 @@ describe('features/search', function() {
}));


it('should prioritize exact match', inject(function(search) {

// given
const items = [
{
title: 'baz foo bar'
},
{
title: 'foo bar baz'
},
{
title: 'foo bar'
}
];

// when
const results = search(items, 'foo bar', {
keys: [
'title'
]
});

// then
expect(results).to.have.length(3);
expect(results[0].item).to.eql(items[2]);
expect(results[1].item).to.eql(items[1]);
expect(results[2].item).to.eql(items[0]);
}));


it('should prioritize start of term', inject(function(search) {

// given
Expand Down

0 comments on commit ff2c23a

Please sign in to comment.