fix: comment move and change events (#7947)

* fix: comment move event

* feat: add support for a drag reason

* fix: comment change events

* chore: add tests for move and change events
This commit is contained in:
Beka Westberg
2024-04-03 19:58:04 +00:00
committed by GitHub
parent 3988e13fbc
commit e75a4fb1d3
5 changed files with 96 additions and 13 deletions

View File

@@ -54,5 +54,45 @@ suite('Workspace comment', function () {
this.workspace.id,
);
});
test('move events are fired when a comment is moved', function () {
this.renderedComment = new Blockly.comments.RenderedWorkspaceComment(
this.workspace,
);
const spy = createChangeListenerSpy(this.workspace);
this.renderedComment.moveTo(new Blockly.utils.Coordinate(42, 42));
assertEventFired(
spy,
Blockly.Events.CommentMove,
{
commentId: this.renderedComment.id,
oldCoordinate_: {x: 0, y: 0},
newCoordinate_: {x: 42, y: 42},
},
this.workspace.id,
);
});
test('change events are fired when a comments text is edited', function () {
this.renderedComment = new Blockly.comments.RenderedWorkspaceComment(
this.workspace,
);
const spy = createChangeListenerSpy(this.workspace);
this.renderedComment.setText('test text');
assertEventFired(
spy,
Blockly.Events.CommentChange,
{
commentId: this.renderedComment.id,
oldContents_: '',
newContents_: 'test text',
},
this.workspace.id,
);
});
});
});