mirror of
https://github.com/google/blockly.git
synced 2026-05-13 15:40:11 +02:00
96758fedd4
* chore: change goog.module to goog.declareModuleId * chore: change test helper exports to esmod exports * chore: change test helpers to use esmodule imports * chore: convert imports of test helpers to esmodule imports * chore: convert other imports in tests to esm imports * fix: make imports use built files * chore: add blockly imports to a bunch of tests * fix: reference Blockly.Blocks instead of Blocks' * fix: properly import generators * chore: fix lint * chore: cleanup from rebase * chore: cleanup from rebase * chore: fix blocks tests
75 lines
2.3 KiB
JavaScript
75 lines
2.3 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.declareModuleId('Blockly.test.blockChangeEvent');
|
|
|
|
import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
|
|
import {defineMutatorBlocks} from './test_helpers/block_definitions.js';
|
|
|
|
|
|
suite('Block Change Event', function() {
|
|
setup(function() {
|
|
sharedTestSetup.call(this);
|
|
this.workspace = new Blockly.Workspace();
|
|
});
|
|
|
|
teardown(function() {
|
|
sharedTestTeardown.call(this);
|
|
});
|
|
|
|
suite('Undo and Redo', function() {
|
|
suite('Mutation', function() {
|
|
setup(function() {
|
|
defineMutatorBlocks();
|
|
});
|
|
|
|
teardown(function() {
|
|
Blockly.Extensions.unregister('xml_mutator');
|
|
Blockly.Extensions.unregister('jso_mutator');
|
|
});
|
|
|
|
suite('XML', function() {
|
|
test('Undo', function() {
|
|
const block = this.workspace.newBlock('xml_block', 'block_id');
|
|
block.domToMutation(
|
|
Blockly.Xml.textToDom('<mutation hasInput="true"/>'));
|
|
const blockChange = new Blockly.Events.BlockChange(
|
|
block, 'mutation', null, '', '<mutation hasInput="true"/>');
|
|
blockChange.run(false);
|
|
chai.assert.isFalse(block.hasInput);
|
|
});
|
|
|
|
test('Redo', function() {
|
|
const block = this.workspace.newBlock('xml_block', 'block_id');
|
|
const blockChange = new Blockly.Events.BlockChange(
|
|
block, 'mutation', null, '', '<mutation hasInput="true"/>');
|
|
blockChange.run(true);
|
|
chai.assert.isTrue(block.hasInput);
|
|
});
|
|
});
|
|
|
|
suite('JSO', function() {
|
|
test('Undo', function() {
|
|
const block = this.workspace.newBlock('jso_block', 'block_id');
|
|
block.loadExtraState({hasInput: true});
|
|
const blockChange = new Blockly.Events.BlockChange(
|
|
block, 'mutation', null, '', '{"hasInput":true}');
|
|
blockChange.run(false);
|
|
chai.assert.isFalse(block.hasInput);
|
|
});
|
|
|
|
test('Redo', function() {
|
|
const block = this.workspace.newBlock('jso_block', 'block_id');
|
|
const blockChange = new Blockly.Events.BlockChange(
|
|
block, 'mutation', null, '', '{"hasInput":true}');
|
|
blockChange.run(true);
|
|
chai.assert.isTrue(block.hasInput);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|