Revert "feat!: allow blocks to receive their own delete events" (#6676)

This commit is contained in:
Beka Westberg
2022-12-01 14:55:31 -08:00
committed by GitHub
parent 089841c26f
commit 67275e4bba
5 changed files with 8 additions and 66 deletions

View File

@@ -11,6 +11,7 @@ import {assertCallBlockStructure, assertDefBlockStructure, createProcDefBlock, c
import {runSerializationTestSuite} from '../test_helpers/serialization.js';
import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from '../test_helpers/setup_teardown.js';
suite('Procedures', function() {
setup(function() {
sharedTestSetup.call(this);
@@ -1209,43 +1210,3 @@ suite('Procedures', function() {
});
});
});
suite('Procedures, dont auto fire events', function() {
setup(function() {
sharedTestSetup.call(this, {fireEventsNow: false});
this.workspace = new Blockly.Workspace();
});
teardown(function() {
sharedTestTeardown.call(this);
});
const testSuites = [
{title: 'procedures_defreturn', hasReturn: true,
defType: 'procedures_defreturn', callType: 'procedures_callreturn'},
{title: 'procedures_defnoreturn', hasReturn: false,
defType: 'procedures_defnoreturn', callType: 'procedures_callnoreturn'},
];
testSuites.forEach((testSuite) => {
suite(testSuite.title, function() {
suite('Disposal', function() {
test('callers are disposed when definitions are disposed', function() {
this.defBlock = new Blockly.Block(this.workspace, testSuite.defType);
this.defBlock.setFieldValue('proc name', 'NAME');
this.callerBlock = new Blockly.Block(
this.workspace, testSuite.callType);
this.callerBlock.setFieldValue('proc name', 'NAME');
// Run the clock now so that the create events get fired. If we fire
// it after disposing, a new procedure def will get created when
// the caller create event is heard.
this.clock.runAll();
this.defBlock.dispose();
this.clock.runAll();
chai.assert.isTrue(this.callerBlock.disposed);
});
});
});
});
});

View File

@@ -21,24 +21,6 @@ suite('Block Delete Event', function() {
sharedTestTeardown.call(this);
});
suite('Receiving', function() {
test('blocks receive their own delete events', function() {
Blockly.Blocks['test'] = {
onchange: function(e) {},
};
// Need to stub the definition, because the property on the definition is
// what gets registered as an event listener.
const spy = sinon.spy(Blockly.Blocks['test'], 'onchange');
const testBlock = this.workspace.newBlock('test');
testBlock.dispose();
const deleteClass = eventUtils.get(eventUtils.BLOCK_DELETE);
chai.assert.isTrue(spy.calledOnce);
chai.assert.isTrue(spy.getCall(0).args[0] instanceof deleteClass);
});
});
suite('Serialization', function() {
test('events round-trip through JSON', function() {
const block = this.workspace.newBlock('row_block', 'block_id');

View File

@@ -19,8 +19,8 @@
<div id="failureCount" style="display:none" tests_failed="unset"></div>
<div id="failureMessages" style="display:none"></div>
<!-- Load mocha et al. before bootstrapping so that we can safely
goog.require() the test modules that make calls to (e.g.)
suite() at the top level. -->
goog.require() the test modules that make calls to (e.g.)
suite() at the top level. -->
<script src="../../node_modules/chai/chai.js"></script>
<script src="../../node_modules/mocha/mocha.js"></script>
<script src="../../node_modules/sinon/pkg/sinon.js"></script>