Check for substring occurence in highlight word module

This commit is contained in:
Jacob Mendt 2016-04-20 15:40:43 +02:00
parent f64bac2fdf
commit f15c6bd3d4
2 changed files with 8 additions and 2 deletions

View File

@ -22,7 +22,7 @@
***************************************************************/
describe('Test suite for the dlfUtils', function() {
var fulltexts = ['Yo Big wake up wake up baby', 'Mmm', 'Yo...', 'Yo Big wake yo ass up c mon'];
var fulltexts = ['Yo Big wake up wake up baby', 'Mmm', 'Yo...', 'Yo Big wake yo ass up c mon', 'Dresden,'];
var features = (function() {
var features = [];
for (var i = 0; i < fulltexts.length; i++) {
@ -51,6 +51,12 @@ describe('Test suite for the dlfUtils', function() {
var response = dlfUtils.searchFeatureCollectionForText(features, 'Mmmm');
expect(response).toBe(undefined);
});
it('Match Dresden in case of "Dresden," given', function() {
var response = dlfUtils.searchFeatureCollectionForText(features, 'Dresden')[0];
expect(response instanceof ol.Feature).toBe(true);
expect(response.get('fulltext')).toBe('Dresden,');
});
});
});

View File

@ -272,7 +272,7 @@ dlfUtils.searchFeatureCollectionForText = function(featureCollection, text) {
var features = [];
featureCollection.forEach(function(ft) {
if (ft.get('fulltext') !== undefined) {
if (ft.get('fulltext').toLowerCase() === text.toLowerCase())
if (ft.get('fulltext').toLowerCase().indexOf(text.toLowerCase()) > -1)
features.push(ft);
}
});