From cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 19:25:40 +0200 Subject: Adding upstream version 7.2.6. Signed-off-by: Daniel Baumann --- tests/js/sphinx_highlight.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/js/sphinx_highlight.js (limited to 'tests/js/sphinx_highlight.js') diff --git a/tests/js/sphinx_highlight.js b/tests/js/sphinx_highlight.js new file mode 100644 index 0000000..1f52eab --- /dev/null +++ b/tests/js/sphinx_highlight.js @@ -0,0 +1,39 @@ +describe('highlightText', function() { + + const cyrillicTerm = 'шеллы'; + const umlautTerm = 'gänsefüßchen'; + + it('should highlight text incl. special characters correctly in HTML', function() { + const highlightTestSpan = new DOMParser().parseFromString( + 'This is the шеллы and Gänsefüßchen test!', 'text/html').body.firstChild + _highlightText(highlightTestSpan, cyrillicTerm, 'highlighted'); + _highlightText(highlightTestSpan, umlautTerm, 'highlighted'); + const expectedHtmlString = + 'This is the шеллы and ' + + 'Gänsefüßchen test!'; + expect(highlightTestSpan.innerHTML).toEqual(expectedHtmlString); + }); + + it('should highlight text incl. special characters correctly in SVG', function() { + const highlightTestSvg = new DOMParser().parseFromString( + '' + + '' + + '' + + 'This is the шеллы and Gänsefüßchen test!' + + '' + + '' + + '', 'text/html').body.firstChild + _highlightText(highlightTestSvg, cyrillicTerm, 'highlighted'); + _highlightText(highlightTestSvg, umlautTerm, 'highlighted'); + /* Note wild cards and ``toMatch``; allowing for some variability + seems to be necessary, even between different FF versions */ + const expectedSvgString = + '' + + '' + + '' + + 'This is the шеллы and ' + + 'Gänsefüßchen test!'; + expect(new XMLSerializer().serializeToString(highlightTestSvg.firstChild)).toMatch(new RegExp(expectedSvgString)); + }); + +}); -- cgit v1.2.3