mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#5258 add tests for highlightText()
This commit is contained in:
parent
b66ea577e8
commit
97fd09177c
@ -1,5 +1,8 @@
|
||||
var DOCUMENTATION_OPTIONS = {};
|
||||
|
||||
|
||||
describe('jQuery extensions', function() {
|
||||
|
||||
describe('urldecode', function() {
|
||||
|
||||
it('should correctly decode URLs and replace `+`s with a spaces', function() {
|
||||
@ -30,3 +33,54 @@ describe('getQueryParameters', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('highlightText', function() {
|
||||
|
||||
var cyrillicTerm = 'шеллы';
|
||||
var umlautTerm = 'gänsefüßchen';
|
||||
|
||||
it('should highlight text incl. special characters correctly in HTML', function() {
|
||||
var highlightTestSpan =
|
||||
jQuery('<span>This is the шеллы and Gänsefüßchen test!</span>');
|
||||
jQuery(document.body).append(highlightTestSpan);
|
||||
highlightTestSpan.highlightText(cyrillicTerm, 'highlighted');
|
||||
highlightTestSpan.highlightText(umlautTerm, 'highlighted');
|
||||
var expectedHtmlString =
|
||||
'This is the <span class=\"highlighted\">шеллы</span> and ' +
|
||||
'<span class=\"highlighted\">Gänsefüßchen</span> test!';
|
||||
expect(highlightTestSpan.html()).toEqual(expectedHtmlString);
|
||||
});
|
||||
|
||||
it('should highlight text incl. special characters correctly in SVG', function() {
|
||||
var highlightTestSvg = jQuery(
|
||||
'<span id="svg-highlight-test">' +
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" height="50" width="500">' +
|
||||
'<text x="0" y="15">' +
|
||||
'This is the шеллы and Gänsefüßchen test!' +
|
||||
'</text>' +
|
||||
'</svg>' +
|
||||
'</span>');
|
||||
$("#svg-highlight-test").html($("#svg-highlight-test").html());
|
||||
jQuery(document.body).append(highlightTestSvg);
|
||||
highlightTestSvg.highlightText(cyrillicTerm, 'highlighted');
|
||||
highlightTestSvg.highlightText(umlautTerm, 'highlighted');
|
||||
var expectedSvgString =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" height="50" width="500">' +
|
||||
'<rect x="-0.5" y="3" width="271.683" height="16" class="highlighted">' +
|
||||
'</rect>' +
|
||||
'<rect x="-0.5" y="3" width="271.683" height="16" class="highlighted">' +
|
||||
'</rect>' +
|
||||
'<text x="0" y="15">' +
|
||||
'This is the ' +
|
||||
'<tspan>шеллы</tspan> and ' +
|
||||
'<tspan>Gänsefüßchen</tspan> test!' +
|
||||
'</text>' +
|
||||
'</svg>';
|
||||
expect(highlightTestSvg.html()).toEqual(expectedSvgString);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user