Skip to content

Commit

Permalink
added test for property option
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Nov 14, 2015
1 parent 63d8ca4 commit 7bdada7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
3 changes: 2 additions & 1 deletion test/page/test.css
Expand Up @@ -101,7 +101,8 @@ a.test-summary.has-failed {

.items-container,
.data-api-items,
.target-items {
.target-items,
.property-items {
overflow: hidden;
margin: 0 -1%;
}
Expand Down
25 changes: 25 additions & 0 deletions test/page/test.html
Expand Up @@ -36,6 +36,11 @@
});
});

// test property
$('.property-items .item').matchHeight({
property: 'min-height'
});

// test target
$('.target-items').each(function() {
$(this).children('.item-0, .item-2, .item-3').matchHeight({
Expand Down Expand Up @@ -369,6 +374,26 @@ <h3>Lorem ipsum dolor</h3>
<p>Phasellus ut nibh fermentum, vulputate urna vel, semper diam.</p>
</div>
</div>

<div class="property-items">
<div class="item item-0">
<h2>min-height</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">
<h3>min-height</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">
<h4>min-height</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">
<h3>min-height</h3>
<p>Aenean semper.</p>
</div>
</div>
</div>
<div id='results'></div>
</body>
Expand Down
22 changes: 21 additions & 1 deletion test/specs/matchHeight.spec.js
Expand Up @@ -2,7 +2,6 @@
// manual testing before going into production is still advised!
// the following features are implemented, but do not have specs yet:

// TODO: spec for $(elements).matchHeight({ property: 'min-height' })
// TODO: spec for $(elements).matchHeight({ remove: true })
// TODO: spec for events: ready, load, resize, orientationchange
// TODO: spec for $.fn.matchHeight._groups
Expand Down Expand Up @@ -252,6 +251,27 @@ describe('matchHeight', function() {
done();
});

it('has applied the property option', function(done) {
var $items = $('.property-items'),
currentBreakpoint = testHelper.getCurrentBreakpoint(),
_parse = $.fn.matchHeight._parse,
item0Value = _parse($items.find('.item-0').css('min-height')),
item1Value = _parse($items.find('.item-1').css('min-height')),
item2Value = _parse($items.find('.item-2').css('min-height')),
item3Value = _parse($items.find('.item-3').css('min-height'));

if (currentBreakpoint === 'tablet') {
expect(item0Value).toBeWithinTolerance(item1Value);
expect(item3Value).toBeWithinTolerance(item2Value);
} else if (currentBreakpoint === 'desktop') {
expect(item0Value).toBeWithinTolerance(item1Value);
expect(item2Value).toBeWithinTolerance(item1Value);
expect(item3Value).toBeWithinTolerance(item1Value);
}

done();
});

it('can manually update heights and fires global callbacks', function(done) {
var currentBreakpoint = testHelper.getCurrentBreakpoint(),
calledBefore = false,
Expand Down

0 comments on commit 7bdada7

Please sign in to comment.