Skip to content

Commit 7bdada7

Browse files
committed
added test for property option
1 parent 63d8ca4 commit 7bdada7

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

test/page/test.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ a.test-summary.has-failed {
101101

102102
.items-container,
103103
.data-api-items,
104-
.target-items {
104+
.target-items,
105+
.property-items {
105106
overflow: hidden;
106107
margin: 0 -1%;
107108
}

test/page/test.html

+25
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
});
3737
});
3838

39+
// test property
40+
$('.property-items .item').matchHeight({
41+
property: 'min-height'
42+
});
43+
3944
// test target
4045
$('.target-items').each(function() {
4146
$(this).children('.item-0, .item-2, .item-3').matchHeight({
@@ -369,6 +374,26 @@ <h3>Lorem ipsum dolor</h3>
369374
<p>Phasellus ut nibh fermentum, vulputate urna vel, semper diam.</p>
370375
</div>
371376
</div>
377+
378+
<div class="property-items">
379+
<div class="item item-0">
380+
<h2>min-height</h2>
381+
<p>Phasellus ut nibh fermentum, vulputate urna vel, semper diam.</p>
382+
<p>Aenean semper felis ipsum, vulputate consequat dui elementum vel.</p>
383+
</div>
384+
<div class="item item-1">
385+
<h3>min-height</h3>
386+
<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>
387+
</div>
388+
<div class="item item-2">
389+
<h4>min-height</h4>
390+
<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>
391+
</div>
392+
<div class="item item-3">
393+
<h3>min-height</h3>
394+
<p>Aenean semper.</p>
395+
</div>
396+
</div>
372397
</div>
373398
<div id='results'></div>
374399
</body>

test/specs/matchHeight.spec.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// manual testing before going into production is still advised!
33
// the following features are implemented, but do not have specs yet:
44

5-
// TODO: spec for $(elements).matchHeight({ property: 'min-height' })
65
// TODO: spec for $(elements).matchHeight({ remove: true })
76
// TODO: spec for events: ready, load, resize, orientationchange
87
// TODO: spec for $.fn.matchHeight._groups
@@ -252,6 +251,27 @@ describe('matchHeight', function() {
252251
done();
253252
});
254253

254+
it('has applied the property option', function(done) {
255+
var $items = $('.property-items'),
256+
currentBreakpoint = testHelper.getCurrentBreakpoint(),
257+
_parse = $.fn.matchHeight._parse,
258+
item0Value = _parse($items.find('.item-0').css('min-height')),
259+
item1Value = _parse($items.find('.item-1').css('min-height')),
260+
item2Value = _parse($items.find('.item-2').css('min-height')),
261+
item3Value = _parse($items.find('.item-3').css('min-height'));
262+
263+
if (currentBreakpoint === 'tablet') {
264+
expect(item0Value).toBeWithinTolerance(item1Value);
265+
expect(item3Value).toBeWithinTolerance(item2Value);
266+
} else if (currentBreakpoint === 'desktop') {
267+
expect(item0Value).toBeWithinTolerance(item1Value);
268+
expect(item2Value).toBeWithinTolerance(item1Value);
269+
expect(item3Value).toBeWithinTolerance(item1Value);
270+
}
271+
272+
done();
273+
});
274+
255275
it('can manually update heights and fires global callbacks', function(done) {
256276
var currentBreakpoint = testHelper.getCurrentBreakpoint(),
257277
calledBefore = false,

0 commit comments

Comments
 (0)