diff --git a/tests/mocha/event_test.js b/tests/mocha/event_test.js
index a85d8a4fa..0a1b39109 100644
--- a/tests/mocha/event_test.js
+++ b/tests/mocha/event_test.js
@@ -574,6 +574,31 @@ suite('Events', function() {
sinon.restore();
});
+ test('Block dispose triggers BlockDelete', function() {
+ try {
+ var toolbox = document.getElementById('toolbox-categories');
+ var workspaceSvg = Blockly.inject('blocklyDiv', {toolbox: toolbox});
+ temporary_fireEvent.firedEvents_ = [];
+
+ var block = workspaceSvg.newBlock('');
+ block.initSvg();
+ block.setCommentText('test comment');
+
+ var event = new Blockly.Events.BlockDelete(block);
+
+ workspaceSvg.clearUndo();
+ block.dispose();
+
+ var firedEvents = workspaceSvg.undoStack_;
+ chai.assert.equal(
+ Blockly.Xml.domToText(firedEvents[0].oldXml),
+ Blockly.Xml.domToText(event.oldXml),
+ 'Delete event created by dispose');
+ } finally {
+ workspaceSvg.dispose();
+ }
+ });
+
test('New block new var', function() {
// Expect three calls to genUid: one to set the block's ID, one for the event
// group's id, and one for the variable's ID.
diff --git a/tests/workspace_svg/event_svg_test.js b/tests/workspace_svg/event_svg_test.js
deleted file mode 100644
index 698a6fffe..000000000
--- a/tests/workspace_svg/event_svg_test.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * @license
- * Copyright 2018 Google LLC
- * SPDX-License-Identifier: Apache-2.0
- */
-'use strict';
-
-
-function eventSvg_setUpMockBlocks() {
- // TODO: Replace with defineGetVarBlock();
- Blockly.defineBlocksWithJsonArray([{
- 'type': 'field_variable_test_block',
- 'message0': '%1',
- 'args0': [
- {
- 'type': 'field_variable',
- 'name': 'VAR',
- 'variable': 'item'
- }
- ],
- },
- {
- 'type': 'simple_test_block',
- 'message0': 'simple test block',
- 'output': null
- },
- {
- 'type': 'test_val_in',
- 'message0': 'test in %1',
- 'args0': [
- {
- 'type': 'input_value',
- 'name': 'NAME'
- }
- ]
- }]);
-}
-
-function eventSvg_tearDownMockBlocks() {
- delete Blockly.Blocks['field_variable_test_block'];
- delete Blockly.Blocks['simple_test_block'];
- delete Blockly.Blocks['test_val_in'];
-}
-
-function eventSvg_createWorkspaceWithToolbox() {
- var toolbox = document.getElementById('toolbox-categories');
- return Blockly.inject('blocklyDiv', {toolbox: toolbox});
-}
-
-function eventSvg_createNewBlock(workspace, type) {
- var block = workspace.newBlock(type);
- block.initSvg();
- return block;
-}
-
-function test_blockDelete_svgDispose() {
- eventSvg_setUpMockBlocks();
- var workspace = eventSvg_createWorkspaceWithToolbox();
- Blockly.Events.fire = temporary_fireEvent;
- temporary_fireEvent.firedEvents_ = [];
- try {
- var block = eventSvg_createNewBlock(workspace);
- block.setCommentText('test comment');
- var event = new Blockly.Events.BlockDelete(block);
- workspace.clearUndo();
- block.dispose();
- var firedEvents = workspace.undoStack_;
- assertEquals('Delete event created by dispose matches constructed delete event',
- Blockly.Xml.domToText(event.oldXml), Blockly.Xml.domToText(firedEvents[0].oldXml));
- } finally {
- eventSvg_tearDownMockBlocks();
- workspace.dispose();
- }
-}
\ No newline at end of file
diff --git a/tests/workspace_svg/index.html b/tests/workspace_svg/index.html
index 9c7f4ad4a..8a0b934f1 100644
--- a/tests/workspace_svg/index.html
+++ b/tests/workspace_svg/index.html
@@ -58,7 +58,6 @@ h1 {
-