feat!: Add support for preserving block comment locations. (#8231)

* feat: Add support for preserving block comment locations.

* chore: format the tests.
This commit is contained in:
Aaron Dodson
2024-06-27 11:11:45 -07:00
committed by GitHub
parent b0b7d78ad0
commit 989c91f626
6 changed files with 158 additions and 5 deletions

View File

@@ -1388,6 +1388,10 @@ suite('Blocks', function () {
return Blockly.utils.Size(0, 0);
}
setBubbleLocation() {}
getBubbleLocation() {}
bubbleIsVisible() {
return true;
}

View File

@@ -141,4 +141,30 @@ suite('Comments', function () {
assertBubbleSize(this.comment, 100, 100);
});
});
suite('Set/Get Bubble Location', function () {
teardown(function () {
sinon.restore();
});
function assertBubbleLocation(comment, x, y) {
const location = comment.getBubbleLocation();
assert.equal(location.x, x);
assert.equal(location.y, y);
}
test('Set Location While Visible', function () {
this.comment.setBubbleVisible(true);
this.comment.setBubbleLocation(new Blockly.utils.Coordinate(100, 100));
assertBubbleLocation(this.comment, 100, 100);
this.comment.setBubbleVisible(false);
assertBubbleLocation(this.comment, 100, 100);
});
test('Set Location While Invisible', function () {
this.comment.setBubbleLocation(new Blockly.utils.Coordinate(100, 100));
assertBubbleLocation(this.comment, 100, 100);
this.comment.setBubbleVisible(true);
assertBubbleLocation(this.comment, 100, 100);
});
});
});