Skip to content

Shape clean up #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 7, 2016
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions test/jasmine/tests/shapes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,33 @@ describe('Test shapes:', function() {

describe('Plotly.relayout', function() {
it('should be able to add a shape', function(done) {
var pathCount = countShapePaths();
var index = countShapes(gd);
var shape = getRandomShape();

Plotly.relayout(gd, 'shapes[' + index + ']', shape).then(function() {
expect(countShapeLayers()).toEqual(1);
expect(countShapePaths()).toEqual(pathCount + 1);
expect(getLastShape(gd)).toEqual(shape);
expect(countShapes(gd)).toEqual(index + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n-riesco nice test. Thanks.

Could you also add an expect(countShapeLayers()) to make sure that the shapes are drawn correctly on relayout?

}).then(done);
});

it('should be able to remove a shape', function(done) {
var pathCount = countShapePaths();
var index = countShapes(gd);
var shape = getRandomShape();

Plotly.relayout(gd, 'shapes[' + index + ']', shape).then(function() {
expect(countShapeLayers()).toEqual(1);
expect(countShapePaths()).toEqual(pathCount + 1);
expect(getLastShape(gd)).toEqual(shape);
expect(countShapes(gd)).toEqual(index + 1);
}).then(function() {
Plotly.relayout(gd, 'shapes[' + index + ']', 'remove');
}).then(function() {
expect(countShapeLayers()).toEqual(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. My bad. I meant expect(countShapeLayerPaths()).

But testing expect(countShapeLayers()) isn't bad either. test 🐅 🐅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... that makes sense. I should've guessed you meant that.

expect(countShapePaths()).toEqual(pathCount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

expect(countShapes(gd)).toEqual(index);
}).then(done);
});
Expand Down