Skip to content

Commit

Permalink
chore(field-*): Remove unneeded uninstallBlocks test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcallen committed Sep 11, 2024
1 parent 00d41eb commit 615a08e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 90 deletions.
30 changes: 0 additions & 30 deletions plugins/field-colour/test/blocks_test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,32 +169,6 @@ const blockJson = {
},
};

/**
* Uninstall old blocks and generators, since they come pre-installed
* with Blockly.
* TODO(#2194): Delete this function and calls to it.
*/
function uninstallBlocks() {
delete Blockly.Blocks['colour_blend'];
delete Blockly.Blocks['colour_rgb'];
delete Blockly.Blocks['colour_random'];
delete Blockly.Blocks['colour_picker'];

const blockNames = [
'colour_blend',
'colour_rgb',
'colour_random',
'colour_picker',
];
blockNames.forEach((name) => {
delete javascriptGenerator.forBlock[name];
delete dartGenerator.forBlock[name];
delete luaGenerator.forBlock[name];
delete pythonGenerator.forBlock[name];
delete phpGenerator.forBlock[name];
});
}

/**
* Assert that the generated code matches the golden code for the specified
* language.
Expand All @@ -212,7 +186,6 @@ function checkResult(suffix, generated) {

suite('Colour Block Generators', function () {
suiteSetup(function () {
uninstallBlocks();
installAllBlocks({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down Expand Up @@ -248,7 +221,4 @@ suite('Colour Block Generators', function () {
teardown(function () {
this.workspace.dispose();
});
suiteTeardown(function () {
uninstallBlocks();
});
});
26 changes: 0 additions & 26 deletions plugins/field-colour/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,31 +240,6 @@ const jsonToolbox = {
],
};

/**
* Uninstall the base colour blocks and their associated generators.
* TODO(#2194): remove this when those blocks are removed from the core library.
*/
function uninstallBlocks() {
delete Blockly.Blocks['colour_blend'];
delete Blockly.Blocks['colour_rgb'];
delete Blockly.Blocks['colour_random'];
delete Blockly.Blocks['colour_picker'];

const blockNames = [
'colour_blend',
'colour_rgb',
'colour_random',
'colour_picker',
];
blockNames.forEach((name) => {
delete javascriptGenerator.forBlock[name];
delete dartGenerator.forBlock[name];
delete luaGenerator.forBlock[name];
delete pythonGenerator.forBlock[name];
delete phpGenerator.forBlock[name];
});
}

/**
* Create a workspace.
*
Expand All @@ -281,7 +256,6 @@ function createWorkspace(
}

document.addEventListener('DOMContentLoaded', function () {
uninstallBlocks();
installColourBlocks({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down
20 changes: 0 additions & 20 deletions plugins/field-multilineinput/test/block_test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {phpGenerator} from 'blockly/php';
import {pythonGenerator} from 'blockly/python';
import {luaGenerator} from 'blockly/lua';
import {installAllBlocks} from '../src/index';
import {BLOCK_NAME} from '../src/blocks/textMultiline';
import {assert} from 'chai';

const blockJson = {
Expand All @@ -39,21 +38,6 @@ const blockJson = {
},
};

/**
* Uninstall old blocks and generators, since they come pre-installed
* with Blockly.
* TODO(#2194): Delete this function and calls to it.
*/
function uninstallBlocks() {
delete Blockly.Blocks[BLOCK_NAME];

delete javascriptGenerator.forBlock[BLOCK_NAME];
delete dartGenerator.forBlock[BLOCK_NAME];
delete luaGenerator.forBlock[BLOCK_NAME];
delete pythonGenerator.forBlock[BLOCK_NAME];
delete phpGenerator.forBlock[BLOCK_NAME];
}

/**
* Assert that the generated code matches the golden code for the specified
* language.
Expand All @@ -72,7 +56,6 @@ function checkResult(suffix, generated) {
suite('Multiline Text Block Generators', function () {
suiteSetup(function () {
Blockly.setLocale(en);
uninstallBlocks();
installAllBlocks({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down Expand Up @@ -108,7 +91,4 @@ suite('Multiline Text Block Generators', function () {
teardown(function () {
this.workspace.dispose();
});
suiteTeardown(function () {
uninstallBlocks();
});
});
14 changes: 0 additions & 14 deletions plugins/field-multilineinput/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,6 @@ const jsonToolbox = {
],
};

/**
* Uninstall the base multiline text block and its associated generators.
* TODO(#2194): remove this when those blocks are removed from the core library.
*/
function uninstallBlock() {
delete Blockly.Blocks['text_multiline'];
delete javascriptGenerator.forBlock['text_multiline'];
delete dartGenerator.forBlock['text_multiline'];
delete luaGenerator.forBlock['text_multiline'];
delete pythonGenerator.forBlock['text_multiline'];
delete phpGenerator.forBlock['text_multiline'];
}

/**
* Create a workspace.
*
Expand All @@ -215,7 +202,6 @@ function createWorkspace(
blocklyDiv: HTMLElement,
options: Blockly.BlocklyOptions,
): Blockly.WorkspaceSvg {
uninstallBlock();
textMultiline.installBlock({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down

0 comments on commit 615a08e

Please sign in to comment.