diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 11:31:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 11:31:33 +0000 |
commit | e863fd965dd6253243c3342bd6f0adc4fc8aec4d (patch) | |
tree | a4c1b6491a82593950043c3f8b2530e80664d768 /tests/js/searchtools.js | |
parent | Initial commit. (diff) | |
download | sphinx-e863fd965dd6253243c3342bd6f0adc4fc8aec4d.tar.xz sphinx-e863fd965dd6253243c3342bd6f0adc4fc8aec4d.zip |
Adding upstream version 5.3.0.upstream/5.3.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/js/searchtools.js')
-rw-r--r-- | tests/js/searchtools.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/js/searchtools.js b/tests/js/searchtools.js new file mode 100644 index 0000000..c9e0c43 --- /dev/null +++ b/tests/js/searchtools.js @@ -0,0 +1,62 @@ +describe('Basic html theme search', function() { + + describe('terms search', function() { + + it('should find "C++" when in index', function() { + index = { + docnames:["index"], + filenames:["index.rst"], + terms:{'c++':0}, + titles:["<no title>"], + titleterms:{} + } + Search.setIndex(index); + searchterms = ['c++']; + excluded = []; + terms = index.terms; + titleterms = index.titleterms; + + hits = [[ + "index", + "<no title>", + "", + null, + 2, + "index.rst" + ]]; + expect(Search.performTermsSearch(searchterms, excluded, terms, titleterms)).toEqual(hits); + }); + + }); + +}); + +// This is regression test for https://github.com/sphinx-doc/sphinx/issues/3150 +describe('splitQuery regression tests', () => { + + it('can split English words', () => { + const parts = splitQuery(' Hello World ') + expect(parts).toEqual(['Hello', 'World']) + }) + + it('can split special characters', () => { + const parts = splitQuery('Pin-Code') + expect(parts).toEqual(['Pin', 'Code']) + }) + + it('can split Chinese characters', () => { + const parts = splitQuery('Hello from 中国 上海') + expect(parts).toEqual(['Hello', 'from', '中国', '上海']) + }) + + it('can split Emoji (surrogate pair) characters. It should keep emojis.', () => { + const parts = splitQuery('😁😁') + expect(parts).toEqual(['😁😁']) + }) + + it('can split umlauts. It should keep umlauts.', () => { + const parts = splitQuery('Löschen Prüfung Abändern ærlig spørsmål') + expect(parts).toEqual(['Löschen', 'Prüfung', 'Abändern', 'ærlig', 'spørsmål']) + }) + +}) |