|
|
@@ -40,6 +40,31 @@ function describeSharedTooltip(desc, fn) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+describe("findHoverIndexFromData", function() {
|
|
|
+ var tooltip = new GraphTooltip(elem, dashboard, scope);
|
|
|
+ var series = { data: [[100, 0], [101, 0], [102, 0], [103, 0], [104, 0], [105, 0], [106, 0], [107, 0]] };
|
|
|
+
|
|
|
+ it("should return 0 if posX out of lower bounds", function() {
|
|
|
+ var posX = 99;
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).to.be(0);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should return n - 1 if posX out of upper bounds", function() {
|
|
|
+ var posX = 108;
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).to.be(series.data.length - 1);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should return i if posX in series", function() {
|
|
|
+ var posX = 104;
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).to.be(4);
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should return i if posX not in series and i + 1 > posX", function() {
|
|
|
+ var posX = 104.9;
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).to.be(4);
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
describeSharedTooltip("steppedLine false, stack false", function(ctx) {
|
|
|
ctx.setup(function() {
|
|
|
ctx.data = [
|
|
|
@@ -168,6 +193,3 @@ describeSharedTooltip("steppedLine false, stack true, individual true", function
|
|
|
expect(ctx.results[1].value).to.be(2);
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
-
|