Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

additional fillHeight test for widget-stdmod

  • Loading branch information...
commit 4e70bf4c4f3fd2870bc644b775d1ecdb0be518fe 1 parent 148e8c6
@clarle authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 src/widget-stdmod/tests/widget-stdmod-test.js
View
28 src/widget-stdmod/tests/widget-stdmod-test.js
@@ -97,6 +97,34 @@ suite.add(new Y.Test.Case({
Assert.areSame('200px', header.getStyle('height'), 'header is not 200px in height.');
},
+ 'fillHeight() should fill up the widget correctly with multiple nodes': function () {
+ var bb, header, body;
+
+ this.widget = new TestWidget({
+ headerContent: 'foo',
+ bodyContent : 'bar',
+ height : 200,
+ render : '#test'
+ });
+
+ bb = this.widget.get('boundingBox');
+ header = this.widget.getStdModNode('header');
+ body = this.widget.getStdModNode('body');
+
+ header.setStyle('height', '50px');
+ body.setStyle('height', '50px');
+
+ Assert.areSame('200px', bb.getStyle('height'), 'widget is not 200px in height before fill.');
+ Assert.areSame('50px', header.getStyle('height'), 'header is not 50px in height before fill.');
+ Assert.areSame('50px', body.getStyle('height'), 'body is not 50px in height before fill.');
+
+ this.widget.fillHeight(body);
+
+ Assert.areSame('200px', bb.getStyle('height'), 'widget is not 200px in height after fill.');
+ Assert.areSame('50px', header.getStyle('height'), 'header is not 50px in height after fill.');
+ Assert.areSame('150px', body.getStyle('height'), 'body is not 150px in height after fill.');
+ },
+
'HTML_PARSER rules should return the proper inner HTML contents from markup': function () {
var src, headerMarkup, footerMarkup, bodyMarkup;

3 comments on commit 4e70bf4

@sdesai

I would add a test the default out of the box behavior. That is, out of the box, if you set a height on a WidgetStdMod widget, the body is supposed to fillHeight by default. It's worth testing this scenario before testing one where you call fillHeight manually [ a bit of an edge case ].

Other variants worth testing are setting the footer, header, null for the fillHeight attribute.

@clarle
Owner

I think the default out-of-the-box behavior was already tested in the other fillHeight test.

https://github.com/clarle/yui3/blob/master/src/widget-stdmod/tests/widget-stdmod-test.js#L64

@sdesai

I don't believe so. That test seems to manually call fillHeight also [ same as yours, and a useful unit test, but not something folks do very often ].

The default is was thinking of being: If I have a WidgetStdMod with a head/body/footer [ 80% use case ], and a height, make sure the body is stretched out to be WidgetHeight - footerHeight - headerHeight (and then the footer/header/null based variants)

e.g: https://github.com/yui/yui3/blob/master/src/overlay/tests/manual/overlay.html#L206
(formalizing some of these tests as unit tests would be a good idea also)

Please sign in to comment.
Something went wrong with that request. Please try again.