Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/blockly/tests/mocha/aria_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import {getInputLabelsSubset} from '#core/block_aria_composer.js';
import {assert} from 'chai';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
Expand All @@ -28,7 +29,10 @@ suite('ARIA', function () {
},
]);
const toolbox = document.getElementById('toolbox-categories');
this.workspace = Blockly.inject('blocklyDiv', {toolbox});
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
toolbox,
});
this.liveRegion = document.getElementById('blocklyAriaAnnounce');
});

Expand Down
28 changes: 15 additions & 13 deletions packages/blockly/tests/mocha/block_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from './test_helpers/events.js';
import {MockBubbleIcon, MockIcon} from './test_helpers/icon_mocks.js';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
workspaceTeardown,
Expand Down Expand Up @@ -479,7 +480,7 @@ suite('Blocks', function () {

suite('Disposing selected shadow block', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
this.parentBlock = this.workspace.newBlock('row_block');
this.parentBlock.initSvg();
this.parentBlock.render();
Expand Down Expand Up @@ -579,7 +580,7 @@ suite('Blocks', function () {

suite('Connection Tracking', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);

this.getInputs = function () {
return this.workspace.connectionDBList[ConnectionType.INPUT_VALUE]
Expand Down Expand Up @@ -1401,6 +1402,7 @@ suite('Blocks', function () {
suite('Rendered', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
comments: true,
scrollbars: true,
});
Expand Down Expand Up @@ -1491,7 +1493,7 @@ suite('Blocks', function () {
}

setup(function () {
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);

this.block = this.workspace.newBlock('stack_block');
this.block.initSvg();
Expand Down Expand Up @@ -1555,7 +1557,7 @@ suite('Blocks', function () {

suite('Getting/Setting Field (Values)', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
this.block = Blockly.Xml.domToBlock(
Blockly.utils.xml.textToDom(
'<block type="text"><field name = "TEXT">test</field></block>',
Expand Down Expand Up @@ -1664,7 +1666,7 @@ suite('Blocks', function () {

suite('Adding icons', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);

this.block = this.workspace.newBlock('stack_block');
this.block.initSvg();
Expand Down Expand Up @@ -1706,7 +1708,7 @@ suite('Blocks', function () {

suite('Removing icons', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);

this.block = this.workspace.newBlock('stack_block');
this.block.initSvg();
Expand Down Expand Up @@ -1806,7 +1808,7 @@ suite('Blocks', function () {

suite('Warning icons', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);

this.block = this.workspace.newBlock('stack_block');
this.block.initSvg();
Expand Down Expand Up @@ -1952,7 +1954,7 @@ suite('Blocks', function () {

suite('Warning icons and collapsing', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
this.parentBlock = Blockly.serialization.blocks.append(
{
'type': 'statement_block',
Expand Down Expand Up @@ -2025,7 +2027,7 @@ suite('Blocks', function () {

suite('Bubbles and collapsing', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
});

teardown(function () {
Expand Down Expand Up @@ -2145,7 +2147,7 @@ suite('Blocks', function () {
setup(function () {
eventUtils.disable();
// We need a visible workspace.
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
Blockly.defineBlocksWithJsonArray([
{
'type': 'variable_block',
Expand Down Expand Up @@ -2724,7 +2726,7 @@ suite('Blocks', function () {
});
suite('Rendered', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
this.block = Blockly.Xml.domToBlock(
Blockly.utils.xml.textToDom('<block type="empty_block"/>'),
this.workspace,
Expand Down Expand Up @@ -2957,7 +2959,7 @@ suite('Blocks', function () {

suite('Dragging', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
this.blocks = createTestBlocks(this.workspace, false);
for (const block of Object.values(this.blocks)) {
block.initSvg();
Expand Down Expand Up @@ -3003,7 +3005,7 @@ suite('Blocks', function () {

suite('Disposal focus management', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
const firstBlock = this.workspace.newBlock('stack_block');
firstBlock.moveBy(-500, -500);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/blockly/tests/mocha/blocks/loops_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import * as Blockly from '#core/blockly.js';
import {assert} from 'chai';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from '../test_helpers/setup_teardown.js';

suite('Loops', function () {
setup(function () {
sharedTestSetup.call(this, {fireEventsNow: false});
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
});

teardown(function () {
Expand Down
3 changes: 2 additions & 1 deletion packages/blockly/tests/mocha/blocks/procedures_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import {runSerializationTestSuite} from '../test_helpers/serialization.js';
import {
createGenUidStubWithReturns,
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
workspaceTeardown,
Expand All @@ -25,7 +26,7 @@ import {
suite('Procedures', function () {
setup(function () {
sharedTestSetup.call(this, {fireEventsNow: false});
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
this.workspace
.getVariableMap()
.createVariable('preCreatedVar', '', 'preCreatedVarId');
Expand Down
17 changes: 12 additions & 5 deletions packages/blockly/tests/mocha/clipboard_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import {
createChangeListenerSpy,
} from './test_helpers/events.js';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';

suite('Clipboard', function () {
setup(function () {
this.clock = sharedTestSetup.call(this, {fireEventsNow: false}).clock;
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
});

teardown(function () {
Expand Down Expand Up @@ -159,7 +160,10 @@ suite('Clipboard', function () {

test('pasted blocks are bumped to not overlap in RTL', function () {
this.workspace.dispose();
this.workspace = Blockly.inject('blocklyDiv', {rtl: true});
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
rtl: true,
});
const block = Blockly.serialization.blocks.append(
{
'type': 'controls_if',
Expand All @@ -182,7 +186,7 @@ suite('Clipboard', function () {

// Restore an LTR workspace.
this.workspace.dispose();
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
});

test('pasted blocks are bumped to be outside the connection snap radius', function () {
Expand Down Expand Up @@ -239,7 +243,10 @@ suite('Clipboard', function () {

test('pasted comments are bumped to not overlap in RTL', function () {
this.workspace.dispose();
this.workspace = Blockly.inject('blocklyDiv', {rtl: true});
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
rtl: true,
});
Blockly.Xml.domToWorkspace(
Blockly.utils.xml.textToDom(
'<xml><comment id="test" x=10 y=10/></xml>',
Expand All @@ -257,7 +264,7 @@ suite('Clipboard', function () {
);
// Restore an LTR workspace.
this.workspace.dispose();
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import {assert} from 'chai';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
Expand All @@ -31,6 +32,7 @@ suite('Comment Deserialization', function () {
</xml>
`;
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
comments: true,
scrollbars: true,
trashcan: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/blockly/tests/mocha/comment_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {EventType} from '#core/events/type.js';
import {assert} from 'chai';
import {assertEventFired} from './test_helpers/events.js';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
Expand All @@ -23,6 +24,7 @@ suite('Comments', function () {
},
]);
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
comments: true,
scrollbars: true,
});
Expand Down
3 changes: 2 additions & 1 deletion packages/blockly/tests/mocha/comment_view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import {assert} from 'chai';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';

suite('Workspace comment', function () {
setup(function () {
sharedTestSetup.call(this);
this.workspace = new Blockly.inject('blocklyDiv', {});
this.workspace = new Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
this.commentView = new Blockly.comments.CommentView(this.workspace);
});

Expand Down
5 changes: 3 additions & 2 deletions packages/blockly/tests/mocha/connection_checker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import {ConnectionType} from '#core/connection_type.js';
import {assert} from 'chai';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
Expand Down Expand Up @@ -515,7 +516,7 @@ suite('Connection checker', function () {
suite('Dragging Checks', function () {
suite('Stacks', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
// Load in three blocks: A and B are connected (next/prev); B is unmovable.
Blockly.Xml.domToWorkspace(
Blockly.utils.xml
Expand Down Expand Up @@ -626,7 +627,7 @@ suite('Connection checker', function () {
});
suite('Rows', function () {
setup(function () {
this.workspace = Blockly.inject('blocklyDiv');
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
// Load 3 blocks: A and B are connected (input/output); B is unmovable.
Blockly.Xml.domToWorkspace(
Blockly.utils.xml
Expand Down
3 changes: 2 additions & 1 deletion packages/blockly/tests/mocha/connection_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from './test_helpers/block_definitions.js';
import {
createGenUidStubWithReturns,
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
workspaceTeardown,
Expand Down Expand Up @@ -101,7 +102,7 @@ suite('Connection', function () {
{
title: 'Rendered',
createWorkspace: () => {
return Blockly.inject('blocklyDiv');
return Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
},
},
{
Expand Down
6 changes: 5 additions & 1 deletion packages/blockly/tests/mocha/contextmenu_items_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import {assert} from 'chai';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
workspaceTeardown,
Expand All @@ -17,7 +18,10 @@ suite('Context Menu Items', function () {

// Creates a WorkspaceSVG
const toolbox = document.getElementById('toolbox-categories');
this.workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
toolbox: toolbox,
});

this.registry = Blockly.ContextMenuRegistry.registry;
this.registry.reset();
Expand Down
6 changes: 5 additions & 1 deletion packages/blockly/tests/mocha/contextmenu_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
defineStackBlock,
} from './test_helpers/block_definitions.js';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
Expand All @@ -22,7 +23,10 @@ suite('Context Menu', function () {

// Creates a WorkspaceSVG
const toolbox = document.getElementById('toolbox-categories');
this.workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});
this.workspace = Blockly.inject('blocklyDiv', {
...DEFAULT_INJECT_OPTIONS,
toolbox: toolbox,
});
});

teardown(function () {
Expand Down
3 changes: 2 additions & 1 deletion packages/blockly/tests/mocha/dialog_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import {assert} from 'chai';
import {
DEFAULT_INJECT_OPTIONS,
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';

suite('Dialog utilities', function () {
setup(function () {
sharedTestSetup.call(this);
this.workspace = Blockly.inject('blocklyDiv', {});
this.workspace = Blockly.inject('blocklyDiv', DEFAULT_INJECT_OPTIONS);
});

teardown(function () {
Expand Down
Loading