|
| 1 | +var d3 = require('d3'); |
1 | 2 | var Scatter = require('@src/traces/scatter');
|
2 | 3 | var makeBubbleSizeFn = require('@src/traces/scatter/make_bubble_size_func');
|
3 | 4 | var linePoints = require('@src/traces/scatter/line_points');
|
4 | 5 | var Lib = require('@src/lib');
|
5 | 6 |
|
| 7 | +var Plotly = require('@lib/index'); |
| 8 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 9 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
| 10 | +var fail = require('../assets/fail_test'); |
| 11 | + |
6 | 12 | describe('Test scatter', function() {
|
7 | 13 | 'use strict';
|
8 | 14 |
|
@@ -326,3 +332,43 @@ describe('Test scatter', function() {
|
326 | 332 | });
|
327 | 333 |
|
328 | 334 | });
|
| 335 | + |
| 336 | +describe('end-to-end scatter tests', function() { |
| 337 | + var gd; |
| 338 | + |
| 339 | + beforeEach(function() { |
| 340 | + gd = createGraphDiv(); |
| 341 | + }); |
| 342 | + |
| 343 | + afterEach(destroyGraphDiv); |
| 344 | + |
| 345 | + it('should add a plotly-customdata class to points with custom data', function(done) { |
| 346 | + Plotly.plot(gd, [{ |
| 347 | + x: [1, 2, 3, 4, 5, 6, 7], |
| 348 | + y: [2, 3, 4, 5, 6, 7, 8], |
| 349 | + customdata: [null, undefined, 0, false, {foo: 'bar'}, 'a'] |
| 350 | + }]).then(function() { |
| 351 | + var points = d3.selectAll('g.scatterlayer').selectAll('.point'); |
| 352 | + |
| 353 | + // Rather than just duplicating the logic, let's be explicit about |
| 354 | + // what's expected. Specifially, only null and undefined (the default) |
| 355 | + // do *not* add the class. |
| 356 | + var expected = [false, false, true, true, true, true, false]; |
| 357 | + |
| 358 | + points.each(function(cd, i) { |
| 359 | + expect(d3.select(this).classed('plotly-customdata')).toBe(expected[i]); |
| 360 | + }); |
| 361 | + |
| 362 | + return Plotly.animate(gd, [{ |
| 363 | + data: [{customdata: []}] |
| 364 | + }], {frame: {redraw: false, duration: 0}}); |
| 365 | + }).then(function() { |
| 366 | + var points = d3.selectAll('g.scatterlayer').selectAll('.point'); |
| 367 | + |
| 368 | + points.each(function() { |
| 369 | + expect(d3.select(this).classed('plotly-customdata')).toBe(false); |
| 370 | + }); |
| 371 | + |
| 372 | + }).catch(fail).then(done); |
| 373 | + }); |
| 374 | +}); |
0 commit comments