This commit is contained in:
38
node_modules/mark.js/test/specs/across-elements/regexp/filter.js
generated
vendored
Normal file
38
node_modules/mark.js/test/specs/across-elements/regexp/filter.js
generated
vendored
Normal 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
38
node_modules/mark.js/test/specs/across-elements/regexp/ignore-groups.js
generated
vendored
Normal file
38
node_modules/mark.js/test/specs/across-elements/regexp/ignore-groups.js
generated
vendored
Normal 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');
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
23
node_modules/mark.js/test/specs/across-elements/regexp/infinite.js
generated
vendored
Normal file
23
node_modules/mark.js/test/specs/across-elements/regexp/infinite.js
generated
vendored
Normal 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);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
17
node_modules/mark.js/test/specs/across-elements/regexp/main.js
generated
vendored
Normal file
17
node_modules/mark.js/test/specs/across-elements/regexp/main.js
generated
vendored
Normal 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);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user