Run tests on Travis-CI.
[dygraphs.git] / auto_tests / tests / per_axis.js
... / ...
CommitLineData
1/**
2 * @fileoverview Tests for per-axis options.
3 *
4 * @author konigsberg@google.com (Robert Konigsberg)
5 */
6
7import Dygraph from '../../src/dygraph';
8import * as utils from '../../src/dygraph-utils';
9
10import Util from './Util';
11import CanvasAssertions from './CanvasAssertions';
12import Proxy from './Proxy';
13
14describe("per-axis", function() {
15
16cleanupAfterEach();
17useProxyCanvas(utils, Proxy);
18
19var xAxisLineColor = "#00ffff";
20var yAxisLineColor = "#ffff00";
21
22var g, graph;
23
24beforeEach(function() {
25 var opts = {
26 axes : {
27 x : {
28 drawAxis : false,
29 drawGrid : false,
30 gridLineColor : xAxisLineColor
31 },
32 y : {
33 drawAxis : false,
34 drawGrid : false,
35 gridLineColor : yAxisLineColor
36 }
37 },
38 colors: [ '#ff0000', '#0000ff' ]
39 };
40
41 var data = "X,Y,Z\n" +
42 "1,1,0\n" +
43 "8,0,1\n"
44 ;
45 graph = document.getElementById('graph');
46 g = new Dygraph(graph, data, opts);
47});
48
49it('testDrawXAxis', function() {
50 g.updateOptions({ axes : { x : { drawAxis: true }} });
51 assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length > 0);
52 assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length == 0);
53});
54
55it('testDrawYAxis', function() {
56 g.updateOptions({ axes : { y : { drawAxis: true }} });
57 assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-x').length ==0);
58 assert.isTrue(graph.getElementsByClassName('dygraph-axis-label-y').length > 0);
59});
60
61it('testDrawXGrid', function() {
62 g.updateOptions({ axes : { x : { drawGrid : true }}});
63 var htx = g.hidden_ctx_;
64 assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) > 0);
65 assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) == 0);
66});
67
68it('testDrawYGrid', function() {
69 g.updateOptions({ axes : { y : { drawGrid : true }}});
70 var htx = g.hidden_ctx_;
71 assert.isTrue(CanvasAssertions.numLinesDrawn(htx, xAxisLineColor) == 0);
72 assert.isTrue(CanvasAssertions.numLinesDrawn(htx, yAxisLineColor) > 0);
73});
74
75});