chore(tests): procedure blocks (#6670)

* chore: sketch out necessary test cases

* chore: add tests for updating the data models

* chore: outline more response tests

* chore: add tests for updating procedure def blocks based on models

* chore: add tests for updating procedure callers based on procedure model updates

* chore: add tests for renaming procedures

* chore: add tests for adding procedure parameters

* chore: add tests for renaming procedure parameters

* chore: add tests for reordering procedure parameters

* chore: add tests for enabling and disabling procedures

* chore: add tests for deleting procedure def

* chore: fixup tests that we accidentally broke

* chore: format
This commit is contained in:
Beka Westberg
2022-12-19 23:18:55 +00:00
committed by GitHub
parent 5456640216
commit 863c985928
3 changed files with 880 additions and 174 deletions

View File

@@ -317,8 +317,6 @@ export class Mutator extends Icon {
return;
}
const block = this.getBlock();
eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))(
block, visible, 'mutator'));
if (visible) {
// Create the bubble.
this.bubble_ = new Bubble(
@@ -390,6 +388,8 @@ export class Mutator extends Icon {
this.sourceListener = null;
}
}
eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))(
block, visible, 'mutator'));
}
/**

File diff suppressed because it is too large Load Diff

View File

@@ -112,19 +112,20 @@ export function assertCallBlockStructure(
* @param {boolean=} hasReturn Whether the procedure definition should have
* return.
* @param {Array<string>=} args An array of argument names.
* @param {string=} name The name of the def block (defaults to 'proc name').
* @return {Blockly.Block} The created block.
*/
export function createProcDefBlock(
workspace, hasReturn = false, args = []) {
workspace, hasReturn = false, args = [], name = 'proc name') {
const type = hasReturn ?
'procedures_defreturn' : 'procedures_defnoreturn';
let xml = '<block type="' + type + '">';
let xml = `<block type="${type}">`;
for (let i = 0; i < args.length; i ++) {
xml +=
' <mutation><arg name="' + args[i] + '"></arg></mutation>\n';
` <mutation><arg name="${args[i]}"></arg></mutation>\n`;
}
xml +=
' <field name="NAME">proc name</field>' +
` <field name="NAME">${name}</field>` +
'</block>';
return Blockly.Xml.domToBlock(Blockly.Xml.textToDom(xml), workspace);
}
@@ -134,15 +135,16 @@ export function createProcDefBlock(
* @param {!Blockly.Workspace} workspace The Blockly workspace.
* @param {boolean=} hasReturn Whether the corresponding procedure definition
* has return.
* @param {string=} name The name of the caller block (defaults to 'proc name').
* @return {Blockly.Block} The created block.
*/
export function createProcCallBlock(
workspace, hasReturn = false) {
workspace, hasReturn = false, name = 'proc name') {
const type = hasReturn ?
'procedures_callreturn' : 'procedures_callnoreturn';
return Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="' + type + '">' +
' <mutation name="proc name"/>' +
'</block>'
`<block type="${type}">` +
` <mutation name="${name}"/>` +
`</block>`
), workspace);
}