fuzzysearch-highlight
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -24,5 +24,3 @@ module.exports = function highlight (query, text, opts) { | ||
if (!after) return null | ||
return before + match + after | ||
} |
{ | ||
"name": "fuzzysearch-highlight", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Highlight fuzzy matched text", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "standard && ava" | ||
}, | ||
@@ -20,4 +20,5 @@ "repository": { | ||
"devDependencies": { | ||
"tape": "^4.0.0" | ||
"ava": "^0.2.0", | ||
"standard": "^5.2.2" | ||
} | ||
} |
26
test.js
@@ -1,6 +0,6 @@ | ||
var test = require('tape') | ||
var test = require('ava') | ||
var highlight = require('./index.js') | ||
test(function (t) { | ||
t.equal( | ||
test('match', function (t) { | ||
t.is( | ||
highlight('tqb', 'The quick brown fox'), | ||
@@ -10,3 +10,3 @@ '<strong>T</strong>he <strong>q</strong>uick <strong>b</strong>rown fox' | ||
t.equal( | ||
t.is( | ||
highlight('quick', 'The quick brown fox'), | ||
@@ -16,9 +16,15 @@ 'The <strong>quick</strong> brown fox' | ||
t.equal( | ||
highlight('zzz', 'The quick brown fox'), | ||
null, | ||
'it returns null if unmatched' | ||
) | ||
t.is(highlight('fox', 'fox'), '<strong>fox</strong>') | ||
t.is(highlight('ox', 'quick fox'), 'quick f<strong>ox</strong>') | ||
t.equal( | ||
t.end() | ||
}) | ||
test('not match', function (t) { | ||
t.is(highlight('zzz', 'The quick brown fox'), null) | ||
t.end() | ||
}) | ||
test('specify tag', function (t) { | ||
t.is( | ||
highlight('quick', 'The quick brown fox', { tag: 'em' }), | ||
@@ -25,0 +31,0 @@ 'The <em>quick</em> brown fox' |
2947
45
2