summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-02-09 08:39:07 +0100
committerGitHub <noreply@github.com>2021-02-09 08:39:07 +0100
commit6c513095e4fb1f898dee84feea3719556759dd58 (patch)
tree0f2ef0a6f050e9e7b77b99f9ddaec304f1b3a4e7 /tests
parentab8739809c8c5f4c1f12e4b15fa8c61afe30ef9f (diff)
parent138f32471c5dfe12299471037782ac353462be74 (diff)
Merge pull request #2553 from danielhones/improve-results-highlighting-updated
Ignore double-quotes when highlighting query parts
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_webutils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.py
index aa464688b..023374b04 100644
--- a/tests/unit/test_webutils.py
+++ b/tests/unit/test_webutils.py
@@ -34,6 +34,28 @@ class TestWebUtils(SearxTestCase):
query = 'a test'
self.assertEqual(webutils.highlight_content(content, query), content)
+ data = (
+ ('" test "',
+ 'a test string',
+ 'a <span class="highlight">test</span> string'),
+ ('"a"',
+ 'this is a test string',
+ 'this is<span class="highlight"> a </span>test string'),
+ ('a test',
+ 'this is a test string that matches entire query',
+ 'this is <span class="highlight">a test</span> string that matches entire query'),
+ ('this a test',
+ 'this is a string to test.',
+ ('<span class="highlight">this</span> is<span class="highlight"> a </span>'
+ 'string to <span class="highlight">test</span>.')),
+ ('match this "exact phrase"',
+ 'this string contains the exact phrase we want to match',
+ ('<span class="highlight">this</span> string contains the <span class="highlight">exact</span>'
+ ' <span class="highlight">phrase</span> we want to <span class="highlight">match</span>'))
+ )
+ for query, content, expected in data:
+ self.assertEqual(webutils.highlight_content(content, query), expected)
+
class TestUnicodeWriter(SearxTestCase):