Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/jasmine/tests/shapes_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
var d3 = require('d3');

var Plotly = require('@lib/index');
var Lib = require('@src/lib');

var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');


describe('Test shapes nodes', function() {
'use strict';

var mock = require('@mocks/shapes.json');
var gd;

beforeEach(function(done) {
gd = createGraphDiv();

var mockData = Lib.extendDeep([], mock.data),
mockLayout = Lib.extendDeep({}, mock.layout);

Plotly.plot(gd, mockData, mockLayout).then(done);
});

afterEach(destroyGraphDiv);

function countShapeLayers() {
return d3.selectAll('.shapelayer').size();
}

function countPaths() {
return d3.selectAll('.shapelayer > path').size();
}

it('has one *shapelayer* node', function() {
expect(countShapeLayers()).toEqual(1);
});

it('has as many *path* nodes as there are shapes', function() {
expect(countPaths()).toEqual(mock.layout.shapes.length);
});

it('should be able to get relayout', function(done) {
expect(countShapeLayers()).toEqual(1);
expect(countPaths()).toEqual(mock.layout.shapes.length);

Plotly.relayout(gd, {height: 200, width: 400}).then(function() {
expect(countShapeLayers()).toEqual(1);
expect(countPaths()).toEqual(mock.layout.shapes.length);
done();
});
});
});