mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
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:
@@ -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,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user