mirror of
https://github.com/google/blockly.git
synced 2026-02-01 21:20:08 +01:00
* feat!: allow blocks to receive their own delete events * fix: move block tests back into main directory * chore: add a test for disposing of callers * chore: add test for delete being received * chore: add comment about why we have to run the clock twice * chore: fix whitespace * chore: fix whitespace * chore: fix imports in tests * chore: bump mocha timeout * chore: bump timeout again? * chore: eliminate the possibility that tests are actually timing out * chore: change timeout back * chore: remove tests that might be the problematic ones * chore: attempt enabling delete event test * chore: enable lists tests * chore: try ternary test as well * chore: actually add block test files * chore: enable remaining tests
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.declareModuleId('Blockly.test.blockDeleteEvent');
|
|
|
|
import * as eventUtils from '../../build/src/core/events/utils.js';
|
|
import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
|
|
|
|
suite('Block Delete Event', function() {
|
|
setup(function() {
|
|
sharedTestSetup.call(this);
|
|
this.workspace = new Blockly.Workspace();
|
|
});
|
|
|
|
teardown(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);
|
|
});
|
|
});
|
|
});
|