Fork off Karma file for in-browser debug
[dygraphs.git] / auto_tests / tests / multi_csv.js
1 /**
2 * @fileoverview Test cases for how axis labels are chosen and formatted.
3 *
4 * @author dan@dygraphs.com (Dan Vanderkam)
5 */
6 describe("multi-csv", function() {
7
8 beforeEach(function() {
9 document.body.innerHTML = "<div id='graph'></div>";
10 });
11
12 afterEach(function() {
13 });
14
15 function getXLabels() {
16 var x_labels = document.getElementsByClassName("dygraph-axis-label-x");
17 var ary = [];
18 for (var i = 0; i < x_labels.length; i++) {
19 ary.push(x_labels[i].innerHTML);
20 }
21 return ary;
22 }
23
24 it('testOneCSV', function() {
25 var opts = {
26 width: 480,
27 height: 320
28 };
29 var data = "X,Y\n" +
30 "0,-1\n" +
31 "1,0\n" +
32 "2,1\n" +
33 "3,0\n"
34 ;
35
36 var graph = document.getElementById("graph");
37 var g = new Dygraph(graph, data, opts);
38
39 assert.deepEqual(['0', '1', '2'], getXLabels());
40 });
41
42 it('testTwoCSV', function() {
43 var opts = {
44 width: 480,
45 height: 320
46 };
47 var data = "X,Y\n" +
48 "0,-1\n" +
49 "1,0\n" +
50 "2,1\n" +
51 "3,0\n"
52 ;
53
54 var graph = document.getElementById("graph");
55 var g = new Dygraph(graph, data, opts);
56
57 assert.deepEqual(['0', '1', '2'], getXLabels());
58
59 g.updateOptions({file: data});
60
61 assert.deepEqual(['0', '1', '2'], getXLabels());
62 });
63
64 });