projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
usage
[dygraphs.git]
/
auto_tests
/
tests
/
custom_bars.js
diff --git
a/auto_tests/tests/custom_bars.js
b/auto_tests/tests/custom_bars.js
index
5b7fd4b
..
ebc867a
100644
(file)
--- a/
auto_tests/tests/custom_bars.js
+++ b/
auto_tests/tests/custom_bars.js
@@
-4,22
+4,29
@@
* @fileoverview Regression test based on some strange customBars data.
* @author danvk@google.com (Dan Vanderkam)
*/
* @fileoverview Regression test based on some strange customBars data.
* @author danvk@google.com (Dan Vanderkam)
*/
-var CustomBarsTestCase = TestCase("custom-bars");
+import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
+import CanvasAssertions from './CanvasAssertions';
+import PixelSampler from './PixelSampler';
+import Proxy from './Proxy';
-_origFunc = Dygraph.getContext;
-CustomBarsTestCase.prototype.setUp = function() {
- document.body.innerHTML = "<div id='graph'></div>";
- Dygraph.getContext = function(canvas) {
+describe("custom-bars", function() {
+
+cleanupAfterEach();
+
+var _origFunc = utils.getContext;
+beforeEach(function() {
+ utils.getContext = function(canvas) {
return new Proxy(_origFunc(canvas));
}
return new Proxy(_origFunc(canvas));
}
-};
+}
)
;
-
CustomBarsTestCase.prototype.tearDown =
function() {
-
Dygraph
.getContext = _origFunc;
-};
+
afterEach(
function() {
+
utils
.getContext = _origFunc;
+}
)
;
// This test used to reliably produce an infinite loop.
// This test used to reliably produce an infinite loop.
-
CustomBarsTestCase.prototype.testCustomBarsNoHang =
function() {
+
it('testCustomBarsNoHang',
function() {
var opts = {
width: 480,
height: 320,
var opts = {
width: 480,
height: 320,
@@
-61,10
+68,10
@@
CustomBarsTestCase.prototype.testCustomBarsNoHang = function() {
"35,,0;22437620;0\n";
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
"35,,0;22437620;0\n";
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
-};
+}
)
;
// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=201
// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=201
-
CustomBarsTestCase.prototype.testCustomBarsZero =
function() {
+
it('testCustomBarsZero',
function() {
var opts = {
customBars: true
};
var opts = {
customBars: true
};
@@
-77,12
+84,12
@@
CustomBarsTestCase.prototype.testCustomBarsZero = function() {
var g = new Dygraph(graph, data, opts);
var range = g.yAxisRange();
var g = new Dygraph(graph, data, opts);
var range = g.yAxisRange();
- assert
True('y-axis must include 0', range[0] <= 0
);
- assert
True('y-axis must include 5', range[1] >= 5
);
-};
+ assert
.isTrue(range[0] <= 0, 'y-axis must include 0'
);
+ assert
.isTrue(range[1] >= 5, 'y-axis must include 5'
);
+}
)
;
// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=229
// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=229
-
CustomBarsTestCase.prototype.testCustomBarsAtTop =
function() {
+
it('testCustomBarsAtTop',
function() {
var g = new Dygraph(document.getElementById("graph"),
[
[1, [10, 10, 100]],
var g = new Dygraph(document.getElementById("graph"),
[
[1, [10, 10, 100]],
@@
-99,27
+106,28
@@
CustomBarsTestCase.prototype.testCustomBarsAtTop = function() {
width: 500, height: 350,
customBars: true,
errorBars: true,
width: 500, height: 350,
customBars: true,
errorBars: true,
- axes
: {
- x
: {
+ axes: {
+ x: {
drawGrid: false,
drawAxis: false,
},
drawGrid: false,
drawAxis: false,
},
- y
: {
+ y: {
drawGrid: false,
drawAxis: false,
}
},
valueRange: [0, 120],
fillAlpha: 0.15,
drawGrid: false,
drawAxis: false,
}
},
valueRange: [0, 120],
fillAlpha: 0.15,
- colors: [ '#00FF00' ]
+ colors: ['#00FF00'],
+ labels: ['X', 'Y']
});
var sampler = new PixelSampler(g);
});
var sampler = new PixelSampler(g);
- assert
Equals
([0, 255, 0, 38], sampler.colorAtCoordinate(5, 60));
-};
+ assert
.deepEqual
([0, 255, 0, 38], sampler.colorAtCoordinate(5, 60));
+}
)
;
// Tests that custom bars work with log scale.
// Tests that custom bars work with log scale.
-
CustomBarsTestCase.prototype.testCustomBarsLogScale =
function() {
+
it('testCustomBarsLogScale',
function() {
var g = new Dygraph(document.getElementById("graph"),
[
[1, [10, 10, 100]],
var g = new Dygraph(document.getElementById("graph"),
[
[1, [10, 10, 100]],
@@
-142,7
+150,8
@@
CustomBarsTestCase.prototype.testCustomBarsLogScale = function() {
},
fillAlpha: 1.0,
logscale: true,
},
fillAlpha: 1.0,
logscale: true,
- colors: [ '#00FF00' ]
+ colors: ['#00FF00'],
+ labels: ['X', 'Y']
});
// The following assertions describe the sides of the custom bars, which are
});
// The following assertions describe the sides of the custom bars, which are
@@
-162,10
+171,9
@@
CustomBarsTestCase.prototype.testCustomBarsLogScale = function() {
[495, 181.66450704318103],
[247.5, 152.02209814465604]],
{ fillStyle: "#00ff00" });
[495, 181.66450704318103],
[247.5, 152.02209814465604]],
{ fillStyle: "#00ff00" });
-};
+}
)
;
-CustomBarsTestCase.prototype.testCustomBarsWithNegativeValuesInLogScale =
- function() {
+it('testCustomBarsWithNegativeValuesInLogScale', function() {
var graph = document.getElementById("graph");
var count = 0;
var graph = document.getElementById("graph");
var count = 0;
@@
-181,15
+189,18
@@
CustomBarsTestCase.prototype.testCustomBarsWithNegativeValuesInLogScale =
],
{
drawPoints: true,
],
{
drawPoints: true,
- drawPointCallback : drawPointCallback,
- customBars: true
+ drawPointCallback: drawPointCallback,
+ customBars: true,
+ labels: ['X', 'Y']
});
// Normally all three points would be drawn.
});
// Normally all three points would be drawn.
- assert
Equals
(3, count);
+ assert
.equal
(3, count);
count = 0;
// In log scale, the third point shouldn't be shown.
g.updateOptions({ logscale : true });
count = 0;
// In log scale, the third point shouldn't be shown.
g.updateOptions({ logscale : true });
- assertEquals(2, count);
-};
+ assert.equal(2, count);
+});
+
+});