Skip to content

Commit

Permalink
added test for remove
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Dec 25, 2015
1 parent 878ff96 commit 445799d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
25 changes: 21 additions & 4 deletions test/page/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -397,20 +397,37 @@ <h3>min-height</h3>

<div class="items-container inline-style-items">
<div class="item item-0" style="display: inline-block">
<h2>min-height</h2>
<h2>inline style</h2>
<p>Phasellus ut nibh fermentum, vulputate urna vel, semper diam.</p>
<p>Aenean semper felis ipsum, vulputate consequat dui elementum vel.</p>
</div>
<div class="item item-1" style="position: relative">
<h3>min-height</h3>
<h3>inline style</h3>
<p>Phasellus ut nibh fermentum, vulputate urna vel, semper diam. Nunc sollicitudin felis ut pellentesque fermentum. In erat mi, pulvinar sit amet tincidunt vitae, gravida id felis. Phasellus hendrerit erat sed porta imperdiet. Vivamus viverra ipsum tortor, et congue mauris porttitor ut.</p>
</div>
<div class="item item-2" style="min-height: 10px">
<h4>min-height</h4>
<h4>inline style</h4>
<p>Aenean semper felis ipsum, vulputate consequat dui elementum vel. Nullam odio eros, sagittis vitae lectus id, pretium viverra lectus. Etiam auctor dolor non dui ultricies pulvinar.</p>
</div>
<div class="item item-3" style="padding: 15px">
<h3>min-height</h3>
<h3>inline style</h3>
<p>Aenean semper.</p>
</div>
</div>

<div class="items-container remove-items">
<div class="item item-0">
<h2>removed</h2>
<p>Phasellus ut nibh fermentum, vulputate urna vel, semper diam.</p>
<p>Aenean semper felis ipsum, vulputate consequat dui elementum vel.</p>
</div>
<div class="item item-1">
<p>Phasellus ut nibh fermentum, vulputate urna vel, semper diam. Nunc sollicitudin felis ut pellentesque fermentum. In erat mi, pulvinar sit amet tincidunt vitae, gravida id felis. Phasellus hendrerit erat sed porta imperdiet. Vivamus viverra ipsum tortor, et congue mauris porttitor ut.</p>
</div>
<div class="item item-2">
<p>Aenean semper felis ipsum, vulputate consequat dui elementum vel. Nullam odio eros, sagittis vitae lectus id, pretium viverra lectus. Etiam auctor dolor non dui ultricies pulvinar.</p>
</div>
<div class="item item-3">
<p>Aenean semper.</p>
</div>
</div>
Expand Down
24 changes: 22 additions & 2 deletions test/specs/matchHeight.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('matchHeight', function() {
expect(1.0001).not.toBeWithinTolerance(0);

$('.simple-items, .image-items, .nested-items-parent, .nested-items,' +
'.fixed-items, .inline-block-items, .inline-flex-items, .items-with-float, .inline-style-items')
'.fixed-items, .inline-block-items, .inline-flex-items, .items-with-float, .inline-style-items, .remove-items')
.each(function() {
var $items = $(this).children('.item'),
rows = $.fn.matchHeight._rows($items);
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('matchHeight', function() {
$.fn.matchHeight._update();

$('.simple-items, .image-items,' +
'.fixed-items, .inline-block-items, .inline-flex-items, .items-with-float, .inline-style-items')
'.fixed-items, .inline-block-items, .inline-flex-items, .items-with-float, .inline-style-items, .remove-items')
.each(function() {
var $items = $(this).children('.item'),
targetHeight = $items.first().outerHeight(),
Expand Down Expand Up @@ -407,6 +407,26 @@ describe('matchHeight', function() {

done();
});

it('can be removed', function(done) {
var matchHeight = $.fn.matchHeight,
$item = $('.remove-items').find('.item-0'),
isInAnyGroup = false;

$item.matchHeight({ remove: true });
expect($item[0].style.height).toBeFalsy();

for (var i = 0; i < matchHeight._groups.length; i += 1) {
var group = matchHeight._groups[i];
if ($.inArray($item[0], group.elements) !== -1) {
isInAnyGroup = true;
break;
}
}

expect(isInAnyGroup).toBeFalsy();
done();
});
});


Expand Down

0 comments on commit 445799d

Please sign in to comment.