2 * @fileoverview Tests for data formats.
4 * @author konigsberg@google.com (Robert Konigsberg)
6 var FormatsTestCase
= TestCase("formats");
8 FormatsTestCase
.prototype.setUp
= function() {
9 document
.body
.innerHTML
= "<div id='graph'></div>";
12 FormatsTestCase
.prototype.tearDown
= function() {
15 FormatsTestCase
.prototype.dataString
=
22 FormatsTestCase
.prototype.dataArray
=
28 FormatsTestCase
.prototype.testCsv
= function() {
29 var data
= this.dataString
;
30 var graph
= document
.getElementById("graph");
31 var g
= new Dygraph(graph
, data
, {});
35 FormatsTestCase
.prototype.testArray
= function() {
36 var data
= this.dataArray
;
37 var graph
= document
.getElementById("graph");
38 var g
= new Dygraph(graph
, data
, {});
42 FormatsTestCase
.prototype.testFunctionReturnsCsv
= function() {
43 var string
= this.dataString
;
44 var data
= function() { return string
; };
46 var graph
= document
.getElementById("graph");
47 var g
= new Dygraph(graph
, data
, {});
48 // this.assertData(g);
52 FormatsTestCase
.prototype.testFunctionDefinesArray
= function() {
53 var array
= this.dataArray
;
54 var data
= function() { return array
; }
56 var graph
= document
.getElementById("graph");
57 var g
= new Dygraph(graph
, data
, {});
61 FormatsTestCase
.prototype.assertData
= function(g
) {
62 var expected
= this.dataArray
;
64 assertEquals(4, g
.numRows());
65 assertEquals(2, g
.numColumns());
67 for (var i
= 0; i
< 4; i
++) {
68 for (var j
= 0; j
< 2; j
++) {
69 assertEquals(expected
[i
][j
], g
.getValue(i
, j
));