widget.html revision 0b9b9d3bda11c4468e6ebac4df222fdb89c9a7b8
3139N/A<!doctype html>
3139N/A<html>
3139N/A<head>
3139N/A <title>Widget Test Suite</title>
3139N/A <link type="text/css" rel="stylesheet" href="/build/test/assets/test-console.css">
3139N/A <style type="text/css">
2516N/A h1 {
3139N/A font: normal 125%/1.4 Arial, sans-serif;
3139N/A }
3139N/A .yui3-skin-sam .yui3-console .yui3-console-content {
3139N/A font-size: 10px;
3139N/A }
3139N/A .yui3-skin-sam .yui3-console-entry-pass .yui3-console-entry-cat {
3139N/A background: #070;
3139N/A color: #fff;
3139N/A }
3139N/A .yui3-skin-sam .yui3-console-entry-fail .yui3-console-entry-cat {
3139N/A background: #700;
3139N/A color: #fff;
3139N/A }
3139N/A .yui3-skin-sam .yui3-console-entry-time {
3139N/A display: none;
3139N/A }
3139N/A </style>
3139N/A</head>
3139N/A<body class="yui3-skin-sam">
3139N/A<div id="testbed" class="yui3-skin-foo"></div>
3139N/A
3139N/A<script src="/build/yui/yui.js"></script>
3139N/A<script>
3139N/AYUI({
3139N/A filter : 'raw'
3139N/A}).use('test','console',function (Y) {
3139N/A
3139N/Avar suite = new Y.Test.Suite("Widget Tests");
3139N/A
3139N/Asuite.add(new Y.Test.Case({
3139N/A name : "getSkinName",
3139N/A
3139N/A "getSkinName should return null if not rendered" : function () {
3139N/A var w = new Y.Widget();
3139N/A
3139N/A Y.Assert.isNull( w.getSkinName() );
3139N/A },
3139N/A
3139N/A "getSkinName should return name from BB if available": function () {
3139N/A var bb = Y.Node.create( '<div class="yui3-skin-foo"><div></div></div>' ),
3139N/A cb = bb.one( 'div' ),
3139N/A w = new Y.Widget( {
3139N/A boundingBox: bb,
3139N/A contentBox: cb
3139N/A } );
3139N/A
3139N/A Y.Assert.areEqual( "foo", w.getSkinName() );
3139N/A },
3139N/A
3139N/A "getSkinName should return name from body or null": function () {
3139N/A var w = new Y.Widget().render(),
3139N/A body = Y.one( 'body' );
3139N/A
3092N/A Y.Assert.areEqual( "sam", w.getSkinName() );
3092N/A
3139N/A body.removeClass( "yui3-skin-sam" );
3139N/A
3139N/A Y.Assert.isNull( w.getSkinName() );
3139N/A
3139N/A body.addClass( "yui3-skin-sam" );
3139N/A },
3139N/A
3139N/A "getSkinName should return name from ancestor if both ancestor and body are classed": function () {
3139N/A var w = new Y.Widget().render( '#testbed' ),
3139N/A body = Y.one( 'body' );
3139N/A
3139N/A body.addClass( "yui3-skin-sam" );
3139N/A
3139N/A Y.Assert.areEqual( "foo", w.getSkinName() );
3139N/A },
3139N/A
3139N/A testRenderedDestroy: function() {
3139N/A var w = new Y.Widget().render();
3139N/A try {
3139N/A w.destroy();
3139N/A } catch(e) {
3139N/A Y.Assert.fail("w.destroy() on a rendered widget threw an exception" + e);
3139N/A }
3139N/A },
3139N/A
3139N/A testUnrenderedDestroy: function() {
3139N/A var w = new Y.Widget();
3139N/A try {
3139N/A w.destroy();
3139N/A } catch(e) {
3139N/A Y.Assert.fail("w.destroy() on an unrendered widget threw an exception" + e);
3139N/A }
3139N/A }
3139N/A
3139N/A}));
3139N/A
3139N/Anew Y.Console({
3139N/A newestOnTop: false,
3139N/A height: '580px'
3139N/A}).render();
3139N/A
3139N/AY.Test.Runner.add(suite);
3139N/A
3139N/AY.Test.Runner.run();
3139N/A
3139N/A});
3139N/A</script>
3139N/A</body>
3139N/A</html>
3139N/A