Skip to content

Instantly share code, notes, and snippets.

@maplpro
Created September 23, 2010 18:03
Show Gist options
  • Save maplpro/594062 to your computer and use it in GitHub Desktop.
Save maplpro/594062 to your computer and use it in GitHub Desktop.
testing with goog.testing
goog.require('goog.testing.asserts');
goog.require('infoportal.ui');
var tb;
function setUp() {
tb = infoportal.ui.init();
}
function tearDown() {
tb.dispose();
}
function testTabBar() {
assertNotNull( tb );
};
function testTabsNumber() {
var i = 0;
tb.forEachChild( function () { i++; } );
assertEquals(5, i);
};
function testSelected() {
first = tb.getSelectedTab();
assertNotNull( first );
assertEquals( 'Enterprise', first.content_ );
};
<!doctype html>
<html>
<head>
<title>Information Portal</title>
</head>
<body>
<div id="menu"></div>
<script src="../closure-library/closure/goog/base.js"></script>
<script>goog.require('goog.testing.jsunit');</script>
<script src="core.js"></script>
<script src="tests.js"></script>
<script>
</script>
</body>
</html>
goog.require( 'goog.ui.TabBar' );
goog.provide( 'infoportal.ui' );
infoportal.ui.init = function () {
tb = new goog.ui.TabBar();
goog.array.forEach(
['Enterprise', 'Farms', 'Web Application', 'Site Collections', 'Sites'],
function (name) {
tb.addChild( new goog.ui.Tab( name ), true );
}
);
tb.setSelectedTabIndex(0);
return tb;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment