1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<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)
{
var suite = new Y.Test.Suite("Y.Charts.Pie"),
//test to ensure that pie charts are drawn from center
PieCenterTest = new Y.Test.Case({
name: "PieChartCenterTest",
setUp: function() {
var myDataValues = [
{day:"Monday", taxes:2000},
{day:"Tuesday", taxes:50},
{day:"Wednesday", taxes:4000},
{day:"Thursday", taxes:200},
{day:"Friday", taxes:2000}
];
var mychart = new Y.Chart({type: "pie", width:400, height:400, dataProvider:myDataValues});
mychart.render("#mychart");
this.chart = mychart;
},
tearDown: function() {
},
testWidthAndHeightEqual: function()
{
var graphic = this.chart.get("graph").get("graphic"),
shapes = graphic.get("shapes"),
i,
shape;
for(i in shapes)
{
if(shapes.hasOwnProperty(i))
{
shape = shapes[i];
}
}
},
testWidthGreaterThanHeight: function()
{
var graphic = this.chart.get("graph").get("graphic"),
shapes,
i,
shape;
this.chart.set("width", 500);
shapes = graphic.get("shapes");
for(i in shapes)
{
if(shapes.hasOwnProperty(i))
{
shape = shapes[i];
}
}
},
testHeightGreaterThanWidth: function()
{
var graphic = this.chart.get("graph").get("graphic"),
shapes,
i,
shape;
this.chart.set("height", 600);
shapes = graphic.get("shapes");
for(i in shapes)
{
if(shapes.hasOwnProperty(i))
{
shape = shapes[i];
}
}
}
});
suite.add(PieCenterTest);
//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>