Skip to content

Commit

Permalink
chore: add tests for move and change events
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Mar 20, 2024
1 parent 68128cb commit 2f7ebcf
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion tests/mocha/workspace_comment_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ suite('Workspace comment', function () {
sharedTestTeardown.call(this);
});

suite('Events', function () {
suite.only('Events', function () {
test('create events are fired when a comment is constructed', function () {
const spy = createChangeListenerSpy(this.workspace);

Expand Down Expand Up @@ -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,
);
});
});
});

0 comments on commit 2f7ebcf

Please sign in to comment.