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
39 lines
916 B
JavaScript
39 lines
916 B
JavaScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {
|
|
sharedTestSetup,
|
|
sharedTestTeardown,
|
|
} from './test_helpers/setup_teardown.js';
|
|
|
|
suite('Comment Change 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('old text');
|
|
const origEvent = new Blockly.Events.CommentChange(
|
|
comment,
|
|
'old text',
|
|
'new text',
|
|
);
|
|
|
|
const json = origEvent.toJson();
|
|
const newEvent = new Blockly.Events.fromJson(json, this.workspace);
|
|
|
|
chai.assert.deepEqual(newEvent, origEvent);
|
|
});
|
|
});
|
|
});
|