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