Files
blockly/tests/mocha/block_create_event_test.js
Rachel Fenichel d11cc047a4 chore: fix more lint (#5700)
* chore: fix 918 violations of comma-dangle rule

* chore: fix 2 violations of comma-spacing

* chore: fix 13 violations of padded-blocks

* chore: fix 50 violations of block-spacing

* chore: fix one violation of semi-spacing

* chore: fix 4 violations of space-before-blocks

* chore: fix 38 violations of object-curly-spacing

* chore: fix 30 violations of key-spacing

* chore: fix 3 violations of quote-props

* chore: fix 5 violations of arrow-parens

* chore: fix 8 violations of no-tabs

* chore: allow uncommented helper functions in mocha tests

* chore: fix several more lint errors

* chore: tweak eslint configuration in core and tests

* chore: rebuild for tests
2021-11-10 10:18:36 -08:00

59 lines
1.5 KiB
JavaScript

/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.module('Blockly.test.blockCreateEvent');
const {assertEventFired, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');
suite('Block Create Event', function() {
setup(function() {
sharedTestSetup.call(this);
this.workspace = new Blockly.Workspace();
});
teardown(function() {
sharedTestTeardown.call(this);
});
test('Create shadow on disconnect', function() {
Blockly.Events.disable();
const block = Blockly.serialization.blocks.append(
{
"type": "text_print",
"inputs": {
"TEXT": {
"shadow": {
"type": "text",
"id": "shadowId",
"fields": {
"TEXT": "abc",
},
},
"block": {
"type": "text",
"fields": {
"TEXT": "",
},
},
},
},
},
this.workspace);
Blockly.Events.enable();
block.getInput('TEXT').connection.disconnect();
assertEventFired(
this.eventsFireStub,
Blockly.Events.BlockCreate,
{'recordUndo': false},
this.workspace.id,
'shadowId');
const calls = this.eventsFireStub.getCalls();
const event = calls[calls.length - 1].args[0];
chai.assert.equal(event.xml.tagName, 'shadow');
});
});