aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/speedometer/c3-master/spec/interaction-spec.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
committerKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
commit0d8bba263dc195147d6fdb09662e7926f0a58b3e (patch)
tree4c570b4376c323e585120e7695b8715be7aa8881 /web/nms.gathering.org/speedometer/c3-master/spec/interaction-spec.js
parente4354b47bd8891c5b1ee591fdf74b3ca67eee461 (diff)
Bump lots of changes
Diffstat (limited to 'web/nms.gathering.org/speedometer/c3-master/spec/interaction-spec.js')
-rw-r--r--web/nms.gathering.org/speedometer/c3-master/spec/interaction-spec.js116
1 files changed, 116 insertions, 0 deletions
diff --git a/web/nms.gathering.org/speedometer/c3-master/spec/interaction-spec.js b/web/nms.gathering.org/speedometer/c3-master/spec/interaction-spec.js
new file mode 100644
index 0000000..4e62070
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/c3-master/spec/interaction-spec.js
@@ -0,0 +1,116 @@
+describe('c3 chart interaction', function () {
+ 'use strict';
+
+ var chart, args;
+
+ beforeEach(function (done) {
+ chart = window.initChart(chart, args, done);
+ });
+
+ describe('generate event rects', function () {
+
+ describe('custom x', function () {
+
+ it('should generate bar chart', function () {
+ args = {
+ data: {
+ x: 'x',
+ columns: [
+ ['x', 0, 1000, 3000, 10000],
+ ['data', 10, 10, 10, 10]
+ ],
+ type: 'bar'
+ }
+ };
+ expect(true).toBeTruthy();
+ });
+
+ it('should have 4 event rects properly', function () {
+ var lefts = [78, 138, 205.5, 407.5],
+ widths = [60, 67.5, 202, 194];
+ d3.selectAll('.c3-event-rect').each(function (d, i) {
+ var box = d3.select(this).node().getBoundingClientRect();
+ expect(box.left).toBeCloseTo(lefts[i], -2);
+ expect(box.width).toBeCloseTo(widths[i], -2);
+ });
+ });
+
+ it('should generate bar chart with only one data', function () {
+ args = {
+ data: {
+ x: 'x',
+ columns: [
+ ['x', 0],
+ ['data', 10]
+ ],
+ type: 'bar'
+ }
+ };
+ expect(true).toBeTruthy();
+ });
+
+ it('should have 1 event rects properly', function () {
+ var eventRects = d3.selectAll('.c3-event-rect');
+ expect(eventRects.size()).toBe(1);
+ eventRects.each(function () {
+ var box = d3.select(this).node().getBoundingClientRect();
+ expect(box.left).toBeCloseTo(40.5, -2);
+ expect(box.width).toBeCloseTo(598, -2);
+ });
+ });
+ });
+
+ describe('timeseries', function () {
+
+ it('should generate line chart with timeseries', function () {
+ args = {
+ data: {
+ x: 'x',
+ columns: [
+ ['x', '20140101', '20140201', '20140210', '20140301'],
+ ['data', 10, 10, 10, 10]
+ ]
+ }
+ };
+ expect(true).toBeTruthy();
+ });
+
+ it('should have 4 event rects properly', function () {
+ var lefts = [43.5, 193, 353, 500],
+ widths = [149.5, 160, 147, 136];
+ d3.selectAll('.c3-event-rect').each(function (d, i) {
+ var box = d3.select(this).node().getBoundingClientRect();
+ expect(box.left).toBeCloseTo(lefts[i], -2);
+ expect(box.width).toBeCloseTo(widths[i], -2);
+ });
+
+ });
+
+ it('should generate line chart with only 1 data timeseries', function () {
+ args = {
+ data: {
+ x: 'x',
+ columns: [
+ ['x', '20140101'],
+ ['data', 10]
+ ]
+ }
+ };
+ expect(true).toBeTruthy();
+ });
+
+ it('should have 1 event rects properly', function () {
+ var eventRects = d3.selectAll('.c3-event-rect');
+ expect(eventRects.size()).toBe(1);
+ eventRects.each(function () {
+ var box = d3.select(this).node().getBoundingClientRect();
+ expect(box.left).toBeCloseTo(40.5, -2);
+ expect(box.width).toBeCloseTo(598, -2);
+ });
+ });
+
+ });
+
+ });
+
+});