<html>
<head>
<style>
/*Supplemental: CSS for the YUI distribution*/
#custom-doc { width: 95%; min-width: 950px; }
#mychart {
padding:10px 10px 10px 10px;
}
</style>
</head>
<body class="yui3-skin-sam">
<h3>Unit Tests</h3>
<div id="mychart"></div>
<script>
YUI({
allowRollup: false,
filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min'
}).use('charts', 'test', 'console', function (Y)
{
//-------------------------------------------------------------------------
// Chart dataProvider Test Case
//-------------------------------------------------------------------------
function ChartDataProviderTestCase(cfg, type)
{
this.attrCfg = cfg;
this.name = type + " DataProvider Tests";
}
Y.extend(ChartDataProviderTestCase, Y.Test.Case, {
//---------------------------------------------------------------------
// Setup and teardown of test harnesses
//---------------------------------------------------------------------
/*
* Sets up several event handlers used to test UserAction mouse events.
*/
setUp : function()
{
//create the chart
this.contentBox = this.chart.get("contentBox");
},
/*
* Removes event handlers that were used during the test.
*/
tearDown : function()
{
this.chart.destroy(true);
},
testKeys: ["revenue", "expenses", "miscellaneous"],
testDefault: function()
{
var chart = this.chart,
testKeys = this.testKeys,
seriesCollection = chart.get("seriesCollection"),
i;
for(i in testKeys)
{
Y.assert(seriesCollection[i] instanceof Y.CartesianSeries);
}
}
});
Y.ChartDataProviderTestCase = ChartDataProviderTestCase;
var suite = new Y.Test.Suite("Y.Charts.DataProvider"),
allPositiveDataProvider = [
],
positiveAndNegativeDataProvider = [
],
allNegativeDataProvider = [
],
decimalDataProvider = [
],
missingDataSmallDataProvider = [
],
missingDataLargeDataProvider = [
],
nullValuesDataProvider = [
],
missingFirstValuesDataProvider = [
],
AllPositiveDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: allPositiveDataProvider
}, "All Positive"),
AllNegativeDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: allNegativeDataProvider
}, "All Negative"),
PositiveAndNegativeDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: positiveAndNegativeDataProvider
}, "Positive and Negative"),
DecimalDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: decimalDataProvider
}, "Decimal");
MissingSmallDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: missingDataSmallDataProvider
}, "Missing Small");
MissingLargeDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: missingDataLargeDataProvider
}, "Missing Large"),
NullValuesDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: nullValuesDataProvider
}, "Null Values"),
MissingFirstValuesDataProviderTest = new Y.ChartDataProviderTestCase({
dataProvider: missingFirstValuesDataProvider
}, "Missing First Values");
suite.add(AllPositiveDataProviderTest);
suite.add(PositiveAndNegativeDataProviderTest);
suite.add(AllNegativeDataProviderTest);
suite.add(DecimalDataProviderTest);
suite.add(MissingSmallDataProviderTest);
suite.add(MissingLargeDataProviderTest);
suite.add(NullValuesDataProviderTest);
suite.add(MissingFirstValuesDataProviderTest);
//create the console
var r = new Y.Console({
newestOnTop : false,
style: 'block' // to anchor in the example content
});
r.render('#testLogger');
//run the tests
Y.Test.Runner.add(suite);
});
</script>
</body>
</html>