mirror of
https://github.com/imezx/Warp.git
synced 2025-04-25 15:40:02 +00:00
35 lines
932 B
JavaScript
35 lines
932 B
JavaScript
'use strict';
|
|
describe('mark with range each callback', function() {
|
|
var $ctx, $elements, ranges;
|
|
beforeEach(function(done) {
|
|
loadFixtures('ranges/each.html');
|
|
|
|
$elements = $();
|
|
$ctx = $('.ranges-each');
|
|
ranges = [];
|
|
new Mark($ctx[0]).markRanges([
|
|
{ start: 20, length: 5 },
|
|
{ start: 64, length: 5 }
|
|
], {
|
|
'each': function(node, range) {
|
|
$elements = $elements.add($(node));
|
|
ranges.push(range);
|
|
},
|
|
'done': done
|
|
});
|
|
});
|
|
|
|
it('should call the each callback for each range element', function() {
|
|
expect($elements).toHaveLength(2);
|
|
});
|
|
it('should pass the correct parameters', function() {
|
|
var textOpts = ['ipsum', 'elitr'];
|
|
$elements.each(function() {
|
|
expect($.inArray($(this).text(), textOpts)).toBeGreaterThan(-1);
|
|
});
|
|
expect(ranges).toEqual([
|
|
{ start: 20, length: 5 },
|
|
{ start: 64, length: 5 }
|
|
]);
|
|
});
|
|
});
|