projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump to version 2 🎉
[dygraphs.git]
/
auto_tests
/
tests
/
annotations.js
diff --git
a/auto_tests/tests/annotations.js
b/auto_tests/tests/annotations.js
index
d0a2f7f
..
3be1936
100644
(file)
--- a/
auto_tests/tests/annotations.js
+++ b/
auto_tests/tests/annotations.js
@@
-3,16
+3,15
@@
*
* @author danvk@google.com (Dan Vanderkam)
*/
*
* @author danvk@google.com (Dan Vanderkam)
*/
-var AnnotationsTestCase = TestCase("annotations");
-AnnotationsTestCase.prototype.setUp = function() {
- document.body.innerHTML = "<div id='graph'></div>";
-};
+import Dygraph from '../../src/dygraph';
+import Util from './Util';
-AnnotationsTestCase.prototype.tearDown = function() {
-};
+describe("annotations", function() {
-AnnotationsTestCase.prototype.testAnnotationsDrawn = function() {
+cleanupAfterEach();
+
+it('testAnnotationsDrawn', function() {
var opts = {
width: 480,
height: 320
var opts = {
width: 480,
height: 320
@@
-43,23
+42,23
@@
AnnotationsTestCase.prototype.testAnnotationsDrawn = function() {
}
]);
}
]);
- assert
Equals
(2, g.annotations().length);
+ assert
.equal
(2, g.annotations().length);
var a1 = document.getElementsByClassName('ann1');
var a1 = document.getElementsByClassName('ann1');
- assert
Equals
(1, a1.length);
+ assert
.equal
(1, a1.length);
a1 = a1[0];
a1 = a1[0];
- assert
Equals
('A', a1.textContent);
+ assert
.equal
('A', a1.textContent);
var a2 = document.getElementsByClassName('ann2');
var a2 = document.getElementsByClassName('ann2');
- assert
Equals
(1, a2.length);
+ assert
.equal
(1, a2.length);
a2 = a2[0];
a2 = a2[0];
- assert
Equals
('B', a2.textContent);
-};
+ assert
.equal
('B', a2.textContent);
+}
)
;
// Some errors that should be flagged:
// 1. Invalid series name (e.g. 'X' or 'non-existent')
// 2. Passing a string as 'x' instead of a number (e.g. x: '1')
// Some errors that should be flagged:
// 1. Invalid series name (e.g. 'X' or 'non-existent')
// 2. Passing a string as 'x' instead of a number (e.g. x: '1')
-
AnnotationsTestCase.prototype.testAnnotationsDontDisappearOnResize =
function() {
+
it('testAnnotationsDontDisappearOnResize',
function() {
var opts = {
};
var data = "X,Y\n" +
var opts = {
};
var data = "X,Y\n" +
@@
-82,23
+81,23
@@
AnnotationsTestCase.prototype.testAnnotationsDontDisappearOnResize = function()
]);
// Check that it displays at all
]);
// Check that it displays at all
- assert
Equals
(1, g.annotations().length);
+ assert
.equal
(1, g.annotations().length);
var a1 = document.getElementsByClassName('ann1');
var a1 = document.getElementsByClassName('ann1');
- assert
Equals
(1, a1.length);
+ assert
.equal
(1, a1.length);
a1 = a1[0];
a1 = a1[0];
- assert
Equals
('A', a1.textContent);
+ assert
.equal
('A', a1.textContent);
// ... and that resizing doesn't kill it.
g.resize(400, 300);
// ... and that resizing doesn't kill it.
g.resize(400, 300);
- assert
Equals
(1, g.annotations().length);
+ assert
.equal
(1, g.annotations().length);
var a1 = document.getElementsByClassName('ann1');
var a1 = document.getElementsByClassName('ann1');
- assert
Equals
(1, a1.length);
+ assert
.equal
(1, a1.length);
a1 = a1[0];
a1 = a1[0];
- assert
Equals
('A', a1.textContent);
-};
+ assert
.equal
('A', a1.textContent);
+}
)
;
// Verify that annotations outside of the visible x-range are not shown.
// Verify that annotations outside of the visible x-range are not shown.
-
AnnotationsTestCase.prototype.testAnnotationsOutOfRangeX =
function() {
+
it('testAnnotationsOutOfRangeX',
function() {
var opts = {
};
var data = "X,Y\n" +
var opts = {
};
var data = "X,Y\n" +
@@
-121,27
+120,27
@@
AnnotationsTestCase.prototype.testAnnotationsOutOfRangeX = function() {
]);
// Check that it displays at all
]);
// Check that it displays at all
- assert
Equals
(1, g.annotations().length);
+ assert
.equal
(1, g.annotations().length);
var a1 = document.getElementsByClassName('ann1');
var a1 = document.getElementsByClassName('ann1');
- assert
Equals
(1, a1.length);
+ assert
.equal
(1, a1.length);
a1 = a1[0];
a1 = a1[0];
- assert
Equals
('A', a1.textContent);
+ assert
.equal
('A', a1.textContent);
// ... and that panning right removes the annotation.
g.updateOptions({dateWindow: [2, 6]});
// ... and that panning right removes the annotation.
g.updateOptions({dateWindow: [2, 6]});
- assert
Equals
(1, g.annotations().length);
+ assert
.equal
(1, g.annotations().length);
a1 = document.getElementsByClassName('ann1');
a1 = document.getElementsByClassName('ann1');
- assert
Equals
(0, a1.length);
+ assert
.equal
(0, a1.length);
// ... and that panning left brings it back.
g.updateOptions({dateWindow: [0, 4]});
// ... and that panning left brings it back.
g.updateOptions({dateWindow: [0, 4]});
- assert
Equals
(1, g.annotations().length);
+ assert
.equal
(1, g.annotations().length);
a1 = document.getElementsByClassName('ann1');
a1 = document.getElementsByClassName('ann1');
- assert
Equals
(1, a1.length);
-};
+ assert
.equal
(1, a1.length);
+}
)
;
// Verify that annotations outside of the visible y-range are not shown.
// Verify that annotations outside of the visible y-range are not shown.
-
AnnotationsTestCase.prototype.testAnnotationsOutOfRangeY =
function() {
+
it('testAnnotationsOutOfRangeY',
function() {
var opts = {
};
var data = "X,Y\n" +
var opts = {
};
var data = "X,Y\n" +
@@
-165,18
+164,18
@@
AnnotationsTestCase.prototype.testAnnotationsOutOfRangeY = function() {
// ... check that panning up removes the annotation.
g.updateOptions({valueRange: [0.5, 2.5]});
// ... check that panning up removes the annotation.
g.updateOptions({valueRange: [0.5, 2.5]});
- assert
Equals
(1, g.annotations().length);
- a1 = document.getElementsByClassName('ann1');
- assert
Equals
(0, a1.length);
+ assert
.equal
(1, g.annotations().length);
+
var
a1 = document.getElementsByClassName('ann1');
+ assert
.equal
(0, a1.length);
// ... and that panning down brings it back.
g.updateOptions({valueRange: [-1, 1]});
// ... and that panning down brings it back.
g.updateOptions({valueRange: [-1, 1]});
- assert
Equals
(1, g.annotations().length);
+ assert
.equal
(1, g.annotations().length);
a1 = document.getElementsByClassName('ann1');
a1 = document.getElementsByClassName('ann1');
- assert
Equals
(1, a1.length);
-};
+ assert
.equal
(1, a1.length);
+}
)
;
-
AnnotationsTestCase.prototype.testAnnotationsDrawnInDrawCallback =
function() {
+
it('testAnnotationsDrawnInDrawCallback',
function() {
var data = "X,Y\n" +
"0,-1\n" +
"1,0\n" +
var data = "X,Y\n" +
"0,-1\n" +
"1,0\n" +
@@
-203,13
+202,13
@@
AnnotationsTestCase.prototype.testAnnotationsDrawnInDrawCallback = function() {
}
});
}
});
- assert
Equals
([true, false], calls);
-};
+ assert
.deepEqual
([true, false], calls);
+}
)
;
// Test that annotations on the same point are stacked.
// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=256
// Test that annotations on the same point are stacked.
// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=256
-
AnnotationsTestCase.prototype.testAnnotationsStacked =
function() {
+
it('testAnnotationsStacked',
function() {
var data = 'X,Y1,Y2\n' +
'0,1,2\n' +
'1,2,3\n';
var data = 'X,Y1,Y2\n' +
'0,1,2\n' +
'1,2,3\n';
@@
-235,15
+234,15
@@
AnnotationsTestCase.prototype.testAnnotationsStacked = function() {
g.setAnnotations(annotations);
var annEls = document.getElementsByClassName('dygraphDefaultAnnotation');
g.setAnnotations(annotations);
var annEls = document.getElementsByClassName('dygraphDefaultAnnotation');
- assert
Equals
(2, annEls.length);
+ assert
.equal
(2, annEls.length);
- assert
Equals
(annEls[0].offsetLeft, annEls[1].offsetLeft);
+ assert
.equal
(annEls[0].offsetLeft, annEls[1].offsetLeft);
assert(annEls[1].offsetTop < annEls[0].offsetTop - 10);
assert(annEls[1].offsetTop < annEls[0].offsetTop - 10);
-};
+}
)
;
// Test the .ready() method, which is most often used with setAnnotations().
// Test the .ready() method, which is most often used with setAnnotations().
-
AnnotationsTestCase.prototype.testReady =
function() {
+
it('testReady',
function() {
var data = 'X,Y1,Y2\n' +
'0,1,2\n' +
'1,2,3\n';
var data = 'X,Y1,Y2\n' +
'0,1,2\n' +
'1,2,3\n';
@@
-258,15
+257,17
@@
AnnotationsTestCase.prototype.testReady = function() {
var ready_calls = 0;
g.ready(function() { ready_calls++; });
var ready_calls = 0;
g.ready(function() { ready_calls++; });
- assert
Equals
(0, ready_calls);
+ assert
.equal
(0, ready_calls);
mockXhr.respond();
mockXhr.respond();
- assert
Equals
(1, ready_calls);
+ assert
.equal
(1, ready_calls);
// Make sure that ready isn't called on redraws.
g.updateOptions({});
// Make sure that ready isn't called on redraws.
g.updateOptions({});
- assert
Equals
(1, ready_calls);
+ assert
.equal
(1, ready_calls);
// Or data changes.
g.updateOptions({file: data});
// Or data changes.
g.updateOptions({file: data});
- assertEquals(1, ready_calls);
-};
+ assert.equal(1, ready_calls);
+});
+
+});