Files
Basalt2/node_modules/mark.js/test/specs/basic/ignore-punctuation-synonyms.js
Robert Jelic b0a4a6da9c Vitepress
2025-02-10 06:53:23 +01:00

43 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
describe('basic mark with ignorePunctuation and synonyms', function() {
function getPunctuation() {
return ':;.,-_(){}[]!\'"+='
.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')
.split('');
}
var $ctx1, $ctx2,
punctuation = getPunctuation();
beforeEach(function(done) {
loadFixtures('basic/ignore-punctuation-synonyms.html');
$ctx1 = $('.basic-ignore-punctuation-synonyms > div:nth-child(1)');
$ctx2 = $('.basic-ignore-punctuation-synonyms > div:nth-child(2)');
new Mark($ctx1[0]).mark('Lorem', {
'separateWordSearch': false,
'diacritics': false,
'ignorePunctuation': punctuation,
'synonyms': {
'Lorem': 'ipsum'
},
'done': function() {
new Mark($ctx2[0]).mark(['one', 'dos', 'lüfte'], {
'separateWordSearch': false,
'diacritics': false,
'ignorePunctuation': punctuation,
'synonyms': {
'ü': 'ue',
'one': 'uno',
'two': 'dos'
},
'done': done
});
}
});
});
it('should wrap synonyms', function() {
expect($ctx1.find('mark')).toHaveLength(8);
expect($ctx2.find('mark')).toHaveLength(9);
});
});