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);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user