widget-stdmod-test.js revision f386d69afd040f61944cff1eaad6cf615c147a6d
624675c154cbb5186e8c760b853ca79835987c9eEric FerraiuoloYUI.add('widget-stdmod-test', function (Y) {
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolovar Assert = Y.Assert,
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo ArrayAssert = Y.ArrayAssert,
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo suite, TestWidget;
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo// -- Suite --------------------------------------------------------------------
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolosuite = new Y.Test.Suite('WidgetStdMod');
624675c154cbb5186e8c760b853ca79835987c9eEric FerraiuoloTestWidget = Y.Base.create('testWidget', Y.Widget, [Y.WidgetStdMod]);
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo// -- Lifecycle ----------------------------------------------------------------
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolosuite.add(new Y.Test.Case({
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo name: 'Lifecycle',
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo tearDown: function () {
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo this.widget && this.widget.destroy();
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo delete this.widget;
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo Y.one('#test').empty();
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo },
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo 'WidgetStdMod should add a `fillHeight` attribute': function () {
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo this.widget = new TestWidget();
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo this.widget.render('#test');
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo Assert.areSame('body', this.widget.get('fillHeight'), '`fillHeight` is not "body".');
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo }
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo}));
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo// -- Methods ------------------------------------------------------------------
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolosuite.add(new Y.Test.Case({
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo name: 'Methods',
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo tearDown: function () {
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo this.widget && this.widget.destroy();
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo delete this.widget;
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo Y.one('#test').empty();
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo },
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo 'getStdModNode() should return the section node if there is content': function () {
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo this.widget = new TestWidget({render: '#test'});
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo Assert.isNull(this.widget.getStdModNode('header'), 'Header node was not null.');
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo this.widget.set('headerContent', 'foo');
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo Assert.isNotNull(this.widget.getStdModNode('header'), 'Header node was null.');
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo },
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo 'getStdModNode() should create the section node when `forceCreate` is truthy': function () {
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo this.widget = new TestWidget({render: '#test'});
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo Assert.isNull(this.widget.getStdModNode('header'), 'Header node was not null.');
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo Assert.isNotNull(this.widget.getStdModNode('header', true), 'Header node was null.');
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo }
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo}));
f386d69afd040f61944cff1eaad6cf615c147a6dEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric FerraiuoloY.Test.Runner.add(suite);
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo}, '@VERSION@', {
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo requires: ['widget-stdmod', 'test']
624675c154cbb5186e8c760b853ca79835987c9eEric Ferraiuolo});