mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
* 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
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {
|
|
sharedTestSetup,
|
|
sharedTestTeardown,
|
|
} from './test_helpers/setup_teardown.js';
|
|
|
|
suite('Comment Delete 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.CommentDelete(comment);
|
|
|
|
const json = origEvent.toJson();
|
|
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
|
|
delete origEvent.xml; // xml fails deep equals for some reason.
|
|
delete newEvent.xml; // xml fails deep equals for some reason.
|
|
|
|
chai.assert.deepEqual(newEvent, origEvent);
|
|
});
|
|
});
|
|
});
|