This commit is contained in:
53
node_modules/mark.js/test/specs/across-elements/basic/accuracy-exactly.js
generated
vendored
Normal file
53
node_modules/mark.js/test/specs/across-elements/basic/accuracy-exactly.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and accuracy exactly', function() {
|
||||
var $ctx1, $ctx2, $ctx3;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/basic/accuracy-exactly.html');
|
||||
|
||||
$ctx1 = $('.across-elements-accuracy-exactly > div:nth-child(1)');
|
||||
$ctx2 = $('.across-elements-accuracy-exactly > div:nth-child(2)');
|
||||
$ctx3 = $('.across-elements-accuracy-exactly > div:nth-child(3)');
|
||||
new Mark($ctx1[0]).mark('ipsu', {
|
||||
'accuracy': 'exactly',
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': function() {
|
||||
new Mark($ctx2[0]).mark('ipsu dolo', {
|
||||
'accuracy': 'exactly',
|
||||
'separateWordSearch': true,
|
||||
'acrossElements': true,
|
||||
'done': function() {
|
||||
new Mark($ctx3[0]).mark('ipsu', {
|
||||
'accuracy': 'exactly',
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': done
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should wrap the right matches', function() {
|
||||
expect($ctx1.find('mark')).toHaveLength(1);
|
||||
expect($ctx1.find('mark').text()).toBe('ipsu');
|
||||
expect($ctx1.find('.not mark')).toHaveLength(0);
|
||||
});
|
||||
it('should work with separateWordSearch', function() {
|
||||
expect($ctx2.find('mark')).toHaveLength(2);
|
||||
var textOpts = ['ipsu', 'dolo'];
|
||||
$ctx2.find('mark').each(function() {
|
||||
expect($.inArray($(this).text(), textOpts)).toBeGreaterThan(-1);
|
||||
});
|
||||
expect($ctx2.find('.not mark')).toHaveLength(0);
|
||||
});
|
||||
it('should work with diacritics', function() {
|
||||
expect($ctx3.find('mark')).toHaveLength(4);
|
||||
var textOpts = ['ipsu', 'ipsü', 'īpsu', 'īpsü'];
|
||||
$ctx3.find('mark').each(function() {
|
||||
expect($.inArray($(this).text(), textOpts)).toBeGreaterThan(-1);
|
||||
});
|
||||
expect($ctx3.find('.not mark')).toHaveLength(0);
|
||||
});
|
||||
});
|
30
node_modules/mark.js/test/specs/across-elements/basic/done.js
generated
vendored
Normal file
30
node_modules/mark.js/test/specs/across-elements/basic/done.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and done callback', function() {
|
||||
var $ctx, doneCalled, totalMatches;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/basic/main.html');
|
||||
|
||||
totalMatches = doneCalled = 0;
|
||||
$ctx = $('.across-elements');
|
||||
new Mark($ctx[0]).mark('lorem ipsum', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': function(counter) {
|
||||
doneCalled++;
|
||||
totalMatches = counter;
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the done callback once only', function(done) {
|
||||
setTimeout(function() {
|
||||
expect(doneCalled).toBe(1);
|
||||
done();
|
||||
}, 3000);
|
||||
});
|
||||
it('should call the done callback with total matches', function() {
|
||||
expect(totalMatches).toBe(6);
|
||||
});
|
||||
});
|
23
node_modules/mark.js/test/specs/across-elements/basic/each.js
generated
vendored
Normal file
23
node_modules/mark.js/test/specs/across-elements/basic/each.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and each callback', function() {
|
||||
var $ctx, eachCalled;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/basic/main.html');
|
||||
|
||||
eachCalled = 0;
|
||||
$ctx = $('.across-elements');
|
||||
new Mark($ctx[0]).mark('lorem ipsum', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'each': function() {
|
||||
eachCalled++;
|
||||
},
|
||||
'done': done
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the each callback for each marked element', function() {
|
||||
expect(eachCalled).toBe(6);
|
||||
});
|
||||
});
|
32
node_modules/mark.js/test/specs/across-elements/basic/empty.js
generated
vendored
Normal file
32
node_modules/mark.js/test/specs/across-elements/basic/empty.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements in an empty context', function() {
|
||||
var $ctx1, $ctx2, done1 = false,
|
||||
done2 = false;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/basic/empty.html');
|
||||
|
||||
$ctx1 = $('.notExistingSelector');
|
||||
$ctx2 = $('.across-elements-empty');
|
||||
new Mark($ctx1[0]).mark('lorem', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': function() {
|
||||
done1 = true;
|
||||
new Mark($ctx2[0]).mark('lorem', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'done': function() {
|
||||
done2 = true;
|
||||
done();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the done function', function() {
|
||||
expect(done1).toBe(true);
|
||||
expect(done2).toBe(true);
|
||||
});
|
||||
});
|
48
node_modules/mark.js/test/specs/across-elements/basic/filter.js
generated
vendored
Normal file
48
node_modules/mark.js/test/specs/across-elements/basic/filter.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and filter callback', function() {
|
||||
var $ctx;
|
||||
beforeEach(function() {
|
||||
loadFixtures('across-elements/basic/filter.html');
|
||||
|
||||
$ctx = $('.across-elements-filter');
|
||||
});
|
||||
|
||||
it('should call the callback with the right parameters', function(done) {
|
||||
var counter = {
|
||||
'lorem': 0,
|
||||
'ipsum': 0,
|
||||
'dolor': 0
|
||||
},
|
||||
totalCounter = 0,
|
||||
calls = 0;
|
||||
try {
|
||||
new Mark($ctx[0]).mark(Object.keys(counter), {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'filter': function(node, term, totalMatches, matches) {
|
||||
expect(node.nodeType).toBe(3);
|
||||
expect($.inArray(
|
||||
term,
|
||||
Object.keys(counter)
|
||||
)).toBeGreaterThan(-1);
|
||||
expect(totalCounter).toBe(totalMatches);
|
||||
expect(counter[term]).toBe(matches);
|
||||
if (++calls !== 3) {
|
||||
counter[term]++;
|
||||
totalCounter++;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
'done': function() {
|
||||
expect($ctx.find('mark')).toHaveLength(15);
|
||||
done();
|
||||
}
|
||||
});
|
||||
} catch (e){
|
||||
done.fail(e.message);
|
||||
}
|
||||
});
|
||||
});
|
20
node_modules/mark.js/test/specs/across-elements/basic/ignore-joiners.js
generated
vendored
Normal file
20
node_modules/mark.js/test/specs/across-elements/basic/ignore-joiners.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and ignoreJoiners', function() {
|
||||
var $ctx;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/basic/ignore-joiners.html');
|
||||
|
||||
$ctx = $('.across-elements-ignore-joiners');
|
||||
new Mark($ctx[0]).mark('lorem ipsum', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'ignoreJoiners': true,
|
||||
'done': done
|
||||
});
|
||||
});
|
||||
|
||||
it('should wrap matches and ignoreJoiners', function() {
|
||||
expect($ctx.find('mark')).toHaveLength(6);
|
||||
});
|
||||
});
|
19
node_modules/mark.js/test/specs/across-elements/basic/main.js
generated
vendored
Normal file
19
node_modules/mark.js/test/specs/across-elements/basic/main.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements', function() {
|
||||
var $ctx;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/basic/main.html');
|
||||
|
||||
$ctx = $('.across-elements');
|
||||
new Mark($ctx[0]).mark('lorem ipsum', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': done
|
||||
});
|
||||
});
|
||||
|
||||
it('should wrap matches', function() {
|
||||
expect($ctx.find('mark')).toHaveLength(6);
|
||||
});
|
||||
});
|
28
node_modules/mark.js/test/specs/across-elements/basic/merge-blanks.js
generated
vendored
Normal file
28
node_modules/mark.js/test/specs/across-elements/basic/merge-blanks.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and multiple blanks', function() {
|
||||
var $ctx1, $ctx2;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/basic/merge-blanks.html');
|
||||
|
||||
$ctx1 = $('.across-elements-merge-blanks > div:nth-child(1)');
|
||||
$ctx2 = $('.across-elements-merge-blanks > div:nth-child(2)');
|
||||
new Mark($ctx1.get()).mark('lorem ipsum', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': function() {
|
||||
new Mark($ctx2.get()).mark('lorem ipsum', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': done
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should wrap matches regardless of the number of blanks', function() {
|
||||
expect($ctx1.find('mark')).toHaveLength(5);
|
||||
expect($ctx2.find('mark')).toHaveLength(5);
|
||||
});
|
||||
});
|
30
node_modules/mark.js/test/specs/across-elements/iframes/across.js
generated
vendored
Normal file
30
node_modules/mark.js/test/specs/across-elements/iframes/across.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and matches across iframes', function() {
|
||||
var $ctx, $elements, errCall;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/iframes/across.html');
|
||||
|
||||
$elements = $();
|
||||
$ctx = $('.across-elements-iframes-across');
|
||||
errCall = 0;
|
||||
try {
|
||||
new Mark($ctx[0]).mark(['dolor sit', 'amet. Lorem'], {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'iframes': true,
|
||||
'acrossElements': true,
|
||||
'each': function($m) {
|
||||
$elements = $elements.add($($m));
|
||||
},
|
||||
'done': done
|
||||
});
|
||||
} catch (e) {
|
||||
errCall++;
|
||||
}
|
||||
}, 30000); // 30 sec timeout
|
||||
|
||||
it('should wrap matches across iframes recursively', function() {
|
||||
expect(errCall).toBe(0);
|
||||
expect($elements).toHaveLength(30); // including whitespace matches
|
||||
});
|
||||
});
|
38
node_modules/mark.js/test/specs/across-elements/iframes/main.js
generated
vendored
Normal file
38
node_modules/mark.js/test/specs/across-elements/iframes/main.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and iframes', function() {
|
||||
var $ctx, $elements, errCall;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/iframes/main.html');
|
||||
|
||||
$elements = $();
|
||||
$ctx = $('.across-elements-iframes');
|
||||
errCall = 0;
|
||||
try {
|
||||
new Mark($ctx[0]).mark('lorem', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'iframes': true,
|
||||
'acrossElements': true,
|
||||
'each': function($m) {
|
||||
$elements = $elements.add($($m));
|
||||
},
|
||||
'done': done
|
||||
});
|
||||
} catch (e) {
|
||||
errCall++;
|
||||
}
|
||||
}, 30000); // 30 sec timeout
|
||||
|
||||
it('should wrap matches inside iframes', function() {
|
||||
expect(errCall).toBe(0);
|
||||
expect($elements).toHaveLength(8);
|
||||
var unequal = false;
|
||||
$elements.each(function() {
|
||||
// make sure that some elements are inside an iframe
|
||||
if ($(this).prop('ownerDocument') !== $ctx.prop('ownerDocument')) {
|
||||
unequal = true;
|
||||
}
|
||||
});
|
||||
expect(unequal).toBe(true);
|
||||
});
|
||||
});
|
30
node_modules/mark.js/test/specs/across-elements/iframes/nested.js
generated
vendored
Normal file
30
node_modules/mark.js/test/specs/across-elements/iframes/nested.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and nested iframes', function() {
|
||||
var $ctx, $elements, errCall;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/iframes/nested.html');
|
||||
|
||||
$elements = $();
|
||||
$ctx = $('.across-elements-iframes-nested');
|
||||
errCall = 0;
|
||||
try {
|
||||
new Mark($ctx[0]).mark('lorem', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'iframes': true,
|
||||
'acrossElements': true,
|
||||
'each': function($m) {
|
||||
$elements = $elements.add($($m));
|
||||
},
|
||||
'done': done
|
||||
});
|
||||
} catch (e) {
|
||||
errCall++;
|
||||
}
|
||||
}, 30000); // 30 sec timeout
|
||||
|
||||
it('should wrap matches inside iframes recursively', function() {
|
||||
expect(errCall).toBe(0);
|
||||
expect($elements).toHaveLength(12);
|
||||
});
|
||||
});
|
19
node_modules/mark.js/test/specs/across-elements/nested/main.js
generated
vendored
Normal file
19
node_modules/mark.js/test/specs/across-elements/nested/main.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
describe('mark with acrossElements and nested matches', function() {
|
||||
var $ctx;
|
||||
beforeEach(function(done) {
|
||||
loadFixtures('across-elements/nested/main.html');
|
||||
|
||||
$ctx = $('.across-elements-nested');
|
||||
new Mark($ctx[0]).mark('lorem ipsum', {
|
||||
'diacritics': false,
|
||||
'separateWordSearch': false,
|
||||
'acrossElements': true,
|
||||
'done': done
|
||||
});
|
||||
});
|
||||
|
||||
it('should wrap matches', function() {
|
||||
expect($ctx.find('mark')).toHaveLength(7);
|
||||
});
|
||||
});
|
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