first-commit
Some checks failed
CI Pipeline / build (push) Failing after 3m23s

This commit is contained in:
2025-08-27 14:05:33 +08:00
commit 9e1b8bdc9d
5159 changed files with 1081326 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
'use strict';
describe(
'mark with acrossElements, regular expression and filter callback',
function() {
var $ctx;
beforeEach(function() {
loadFixtures('across-elements/regexp/filter.html');
$ctx = $('.across-elements-regexp-filter');
});
it(
'should call the callback with the right parameters',
function(done) {
var k = 0,
textOpts = ['Lorem', 'ipsum'];
new Mark($ctx[0]).markRegExp(/(Lore?m)|(ipsum)/gmi, {
'acrossElements': true,
'filter': function(node, term, totalMatches) {
expect(node.nodeType).toBe(3);
expect($.inArray(term, textOpts)).toBeGreaterThan(-1);
expect(k).toBe(totalMatches);
if (term !== 'ipsum') {
k++;
return true;
} else {
return false;
}
},
'done': function() {
expect($ctx.find('mark')).toHaveLength(4);
done();
}
});
}
);
}
);

View File

@@ -0,0 +1,38 @@
'use strict';
describe(
'mark with acrossElements, regular expression and ignoreGroups',
function() {
var $ctx1, $ctx2, prefix = 'across-elements-regexp';
beforeEach(function(done) {
loadFixtures('across-elements/regexp/ignore-groups.html');
$ctx1 = $('.' + prefix + '-ignore-groups > div:first-child');
$ctx2 = $('.' + prefix + '-ignore-groups > div:last-child');
new Mark($ctx1[0]).markRegExp(/(Lor)([^]?m[\s]*)(ipsum)/gmi, {
'acrossElements': true,
'done': function() {
new Mark($ctx2[0]).markRegExp(
/(Lor)([^]?m[\s]*)(ipsum)/gmi, {
'acrossElements': true,
'ignoreGroups': 2,
'done': done
}
);
}
});
});
it('should silently ignore groups when disabled', function() {
expect($ctx1.find('mark')).toHaveLength(4);
$ctx1.find('mark').each(function() {
expect($(this).text()).toBe('Lorem ipsum');
});
});
it('should ignore specified groups when enabled', function() {
expect($ctx2.find('mark')).toHaveLength(4);
$ctx2.find('mark').each(function() {
expect($(this).text()).toBe('ipsum');
});
});
}
);

View File

@@ -0,0 +1,23 @@
'use strict';
describe(
'mark with acrossElements and regular expression with infinite matches',
function() {
var $ctx;
beforeEach(function(done) {
loadFixtures('across-elements/regexp/infinite.html');
$ctx = $('.across-elements-regexp-infinite');
new Mark($ctx[0]).markRegExp(/(|)/gmi, {
'acrossElements': true,
'done': done
});
});
it(
'should not mark regular expressions with infinite matches',
function() {
expect($ctx.find('mark')).toHaveLength(0);
}
);
}
);

View File

@@ -0,0 +1,17 @@
'use strict';
describe('mark with acrossElements and regular expression', function() {
var $ctx;
beforeEach(function(done) {
loadFixtures('across-elements/regexp/main.html');
$ctx = $('.across-elements-regexp');
new Mark($ctx[0]).markRegExp(/lorem[\s]+ipsum/gmi, {
'acrossElements': true,
'done': done
});
});
it('should wrap matches', function() {
expect($ctx.find('mark')).toHaveLength(6);
});
});