Files
blockly/tests/mocha/event_comment_move_test.js
Beka Westberg 63eb4ecb2a fix: comment create and delete events (#7945)
* chore: switch events to use new comment class

* fix: switch create and delete events to use JSON

* work on getting new comments to fire events

* chore: fixup tests

* chore: rename workspace comment test to comment view test

* chore: add tests for firing events

* chore: remove TODO
2024-04-01 21:33:50 +00:00

40 lines
1.1 KiB
JavaScript

/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
suite('Comment Move Event', function () {
setup(function () {
sharedTestSetup.call(this);
this.workspace = new Blockly.Workspace();
});
teardown(function () {
sharedTestTeardown.call(this);
});
suite('Serialization', function () {
test('events round-trip through JSON', function () {
const comment = new Blockly.comments.WorkspaceComment(this.workspace);
comment.setText('test text');
comment.moveTo(new Blockly.utils.Coordinate(10, 10));
const origEvent = new Blockly.Events.CommentMove(comment);
comment.moveTo(new Blockly.utils.Coordinate(20, 20));
origEvent.recordNew();
const json = origEvent.toJson();
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
delete origEvent.comment_; // Ignore private properties.
delete newEvent.comment_; // Ignore private properties.
chai.assert.deepEqual(newEvent, origEvent);
});
});
});