chore: replace var with let and const in mocha tests (#5638)

* chore: replace var with let and const in mocha tests

* chore: change let to const in changed lines
This commit is contained in:
Rachel Fenichel
2021-10-26 11:02:36 -07:00
committed by GitHub
parent 44525754a6
commit 0ae10fe516
10 changed files with 170 additions and 178 deletions

View File

@@ -1313,24 +1313,24 @@ suite('Blocks', function() {
suite('Collapsing and Expanding', function() {
function assertCollapsed(block, opt_string) {
chai.assert.isTrue(block.isCollapsed());
for (var i = 0, input; (input = block.inputList[i]); i++) {
for (let i = 0, input; (input = block.inputList[i]); i++) {
if (input.name == Blockly.Block.COLLAPSED_INPUT_NAME) {
continue;
}
chai.assert.isFalse(input.isVisible());
for (var j = 0, field; (field = input.fieldRow[j]); j++) {
for (let j = 0, field; (field = input.fieldRow[j]); j++) {
chai.assert.isFalse(field.isVisible());
}
}
let icons = block.getIcons();
for (var i = 0, icon; (icon = icons[i]); i++) {
for (let i = 0, icon; (icon = icons[i]); i++) {
chai.assert.isFalse(icon.isVisible());
}
var input = block.getInput(Blockly.Block.COLLAPSED_INPUT_NAME);
const input = block.getInput(Blockly.Block.COLLAPSED_INPUT_NAME);
chai.assert.isNotNull(input);
chai.assert.isTrue(input.isVisible());
var field = block.getField(Blockly.Block.COLLAPSED_FIELD_NAME);
const field = block.getField(Blockly.Block.COLLAPSED_FIELD_NAME);
chai.assert.isNotNull(field);
chai.assert.isTrue(field.isVisible());
@@ -1340,16 +1340,16 @@ suite('Blocks', function() {
}
function assertNotCollapsed(block) {
chai.assert.isFalse(block.isCollapsed());
for (var i = 0, input; (input = block.inputList[i]); i++) {
for (let i = 0, input; (input = block.inputList[i]); i++) {
chai.assert.isTrue(input.isVisible());
for (var j = 0, field; (field = input.fieldRow[j]); j++) {
for (let j = 0, field; (field = input.fieldRow[j]); j++) {
chai.assert.isTrue(field.isVisible());
}
}
var input = block.getInput(Blockly.Block.COLLAPSED_INPUT_NAME);
const input = block.getInput(Blockly.Block.COLLAPSED_INPUT_NAME);
chai.assert.isNull(input);
var field = block.getField(Blockly.Block.COLLAPSED_FIELD_NAME);
const field = block.getField(Blockly.Block.COLLAPSED_FIELD_NAME);
chai.assert.isNull(field);
}
function isBlockHidden(block) {

View File

@@ -105,7 +105,7 @@ suite('Connection', function() {
chai.assert.notExists(block,
`expected block ${block && block.id} to not be attached to next connection`);
}
function assertSerialization(block, jso, xmlText) {
const actualJso = Blockly.serialization.blocks
.save(block, {addNextBlocks: true});
@@ -156,21 +156,21 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStatementBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="statement_block" id="id0"/>'
), workspace);
return block;
}
function createStackBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="stack_block" id="id0"/>'
), workspace);
return block;
}
test('Value', function() {
let parent = createRowBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -200,7 +200,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Value', function() {
let parent = createRowBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -248,7 +248,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -278,7 +278,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Statement', function() {
let parent = createStatementBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -326,7 +326,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -354,7 +354,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Next', function() {
let parent = createStackBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -398,7 +398,7 @@ suite('Connection', function() {
);
});
});
suite('Add - With Block Connected', function() {
// These are defined separately in each suite.
function createRowBlocks(workspace) {
@@ -411,7 +411,7 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStatementBlocks(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="statement_block" id="id0">' +
@@ -422,7 +422,7 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStackBlocks(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="stack_block" id="id0">' +
@@ -433,7 +433,7 @@ suite('Connection', function() {
), workspace);
return block;
}
test('Value', function() {
let parent = createRowBlocks(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -465,7 +465,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Value', function() {
let parent = createRowBlocks(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -516,7 +516,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlocks(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -548,7 +548,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Statement', function() {
let parent = createStatementBlocks(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -600,7 +600,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlocks(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -630,7 +630,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Next', function() {
let parent = createStackBlocks(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -677,7 +677,7 @@ suite('Connection', function() {
);
});
});
suite('Add - With Shadow Connected', function() {
// These are defined separately in each suite.
function createRowBlock(workspace) {
@@ -686,32 +686,31 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStatementBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="statement_block" id="id0"/>'
), workspace);
return block;
}
function createStackBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="stack_block" id="id0"/>'
), workspace);
return block;
}
test('Value', function() {
let parent = createRowBlock(this.workspace);
var xml = Blockly.Xml.textToDom(
const parent = createRowBlock(this.workspace);
const xml1 = Blockly.Xml.textToDom(
'<shadow type="row_block" id="1"/>'
);
parent.getInput('INPUT').connection.setShadowDom(xml);
parent.getInput('INPUT').connection.setShadowDom(xml1);
assertInputHasBlock(parent, 'INPUT', true, '1');
var xml = Blockly.Xml.textToDom(
'<shadow type="row_block" id="2"/>'
);
parent.getInput('INPUT').connection.setShadowDom(xml);
const xml2 =
Blockly.Xml.textToDom('<shadow type="row_block" id="2"/>');
parent.getInput('INPUT').connection.setShadowDom(xml2);
assertInputHasBlock(parent, 'INPUT', true, '2');
assertSerialization(
parent,
@@ -735,28 +734,26 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Value', function() {
let parent = createRowBlock(this.workspace);
var xml = Blockly.Xml.textToDom(
const parent = createRowBlock(this.workspace);
const xml1 = Blockly.Xml.textToDom(
'<shadow type="row_block" id="1">' +
' <value name="INPUT">' +
' <shadow type="row_block" id="a"/>' +
' </value>' +
'</shadow>'
);
parent.getInput('INPUT').connection.setShadowDom(xml);
'</shadow>');
parent.getInput('INPUT').connection.setShadowDom(xml1);
assertInputHasBlock(parent, 'INPUT', true, '1');
assertInputHasBlock(
parent.getInputTargetBlock('INPUT'), 'INPUT', true, 'a');
var xml = Blockly.Xml.textToDom(
const xml2 = Blockly.Xml.textToDom(
'<shadow type="row_block" id="2">' +
' <value name="INPUT">' +
' <shadow type="row_block" id="b"/>' +
' </value>' +
'</shadow>'
);
parent.getInput('INPUT').connection.setShadowDom(xml);
'</shadow>');
parent.getInput('INPUT').connection.setShadowDom(xml2);
assertInputHasBlock(parent, 'INPUT', true, '2');
assertInputHasBlock(
parent.getInputTargetBlock('INPUT'), 'INPUT', true, 'b');
@@ -794,18 +791,16 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlock(this.workspace);
var xml = Blockly.Xml.textToDom(
'<shadow type="statement_block" id="1"/>'
);
parent.getInput('NAME').connection.setShadowDom(xml);
const parent = createStatementBlock(this.workspace);
const xml1 = Blockly.Xml.textToDom(
'<shadow type="statement_block" id="1"/>');
parent.getInput('NAME').connection.setShadowDom(xml1);
assertInputHasBlock(parent, 'NAME', true, '1');
var xml = Blockly.Xml.textToDom(
'<shadow type="statement_block" id="2"/>'
);
parent.getInput('NAME').connection.setShadowDom(xml);
const xml2 = Blockly.Xml.textToDom(
'<shadow type="statement_block" id="2"/>');
parent.getInput('NAME').connection.setShadowDom(xml2);
assertInputHasBlock(parent, 'NAME', true, '2');
assertSerialization(
parent,
@@ -829,28 +824,26 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Statement', function() {
let parent = createStatementBlock(this.workspace);
var xml = Blockly.Xml.textToDom(
const parent = createStatementBlock(this.workspace);
const xml1 = Blockly.Xml.textToDom(
'<shadow type="statement_block" id="1">' +
' <statement name="NAME">' +
' <shadow type="statement_block" id="a"/>' +
' </statement>' +
'</shadow>'
);
parent.getInput('NAME').connection.setShadowDom(xml);
'</shadow>');
parent.getInput('NAME').connection.setShadowDom(xml1);
assertInputHasBlock(parent, 'NAME', true, '1');
assertInputHasBlock(
parent.getInputTargetBlock('NAME'), 'NAME', true, 'a');
var xml = Blockly.Xml.textToDom(
const xml2 = Blockly.Xml.textToDom(
'<shadow type="statement_block" id="2">' +
' <statement name="NAME">' +
' <shadow type="statement_block" id="b"/>' +
' </statement>' +
'</shadow>'
);
parent.getInput('NAME').connection.setShadowDom(xml);
'</shadow>');
parent.getInput('NAME').connection.setShadowDom(xml2);
assertInputHasBlock(parent, 'NAME', true, '2');
assertInputHasBlock(
parent.getInputTargetBlock('NAME'), 'NAME', true, 'b');
@@ -888,18 +881,16 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlock(this.workspace);
var xml = Blockly.Xml.textToDom(
'<shadow type="stack_block" id="1"/>'
);
parent.nextConnection.setShadowDom(xml);
const parent = createStackBlock(this.workspace);
const xml1 =
Blockly.Xml.textToDom('<shadow type="stack_block" id="1"/>');
parent.nextConnection.setShadowDom(xml1);
assertNextHasBlock(parent, true, '1');
var xml = Blockly.Xml.textToDom(
'<shadow type="stack_block" id="2"/>'
);
parent.nextConnection.setShadowDom(xml);
const xml2 =
Blockly.Xml.textToDom('<shadow type="stack_block" id="2"/>');
parent.nextConnection.setShadowDom(xml2);
assertNextHasBlock(parent, true, '2');
assertSerialization(
parent,
@@ -921,27 +912,25 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Next', function() {
let parent = createStackBlock(this.workspace);
var xml = Blockly.Xml.textToDom(
const parent = createStackBlock(this.workspace);
const xml1 = Blockly.Xml.textToDom(
'<shadow type="stack_block" id="1">' +
' <next>' +
' <shadow type="stack_block" id="a"/>' +
' </next>' +
'</shadow>'
);
parent.nextConnection.setShadowDom(xml);
'</shadow>');
parent.nextConnection.setShadowDom(xml1);
assertNextHasBlock(parent, true, '1');
assertNextHasBlock(parent.getNextBlock(), true, 'a');
var xml = Blockly.Xml.textToDom(
const xml2 = Blockly.Xml.textToDom(
'<shadow type="stack_block" id="2">' +
' <next>' +
' <shadow type="stack_block" id="b"/>' +
' </next>' +
'</shadow>'
);
parent.nextConnection.setShadowDom(xml);
'</shadow>');
parent.nextConnection.setShadowDom(xml2);
assertNextHasBlock(parent, true, '2');
assertNextHasBlock(parent.getNextBlock(), true, 'b');
assertSerialization(
@@ -975,7 +964,7 @@ suite('Connection', function() {
);
});
});
suite('Remove - No Block Connected', function() {
// These are defined separately in each suite.
function createRowBlock(workspace) {
@@ -988,7 +977,7 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStatementBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="statement_block" id="id0">' +
@@ -999,7 +988,7 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStackBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="stack_block" id="id0">' +
@@ -1010,7 +999,7 @@ suite('Connection', function() {
), workspace);
return block;
}
test('Value', function() {
let parent = createRowBlock(this.workspace);
parent.getInput('INPUT').connection.setShadowDom(null);
@@ -1026,7 +1015,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlock(this.workspace);
parent.getInput('NAME').connection.setShadowDom(null);
@@ -1042,7 +1031,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlock(this.workspace);
parent.nextConnection.setShadowDom(null);
@@ -1059,7 +1048,7 @@ suite('Connection', function() {
);
});
});
suite('Remove - Block Connected', function() {
// These are defined separately in each suite.
function createRowBlock(workspace) {
@@ -1073,7 +1062,7 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStatementBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="statement_block" id="id0">' +
@@ -1085,7 +1074,7 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStackBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="stack_block" id="id0">' +
@@ -1097,7 +1086,7 @@ suite('Connection', function() {
), workspace);
return block;
}
test('Value', function() {
let parent = createRowBlock(this.workspace);
parent.getInput('INPUT').connection.setShadowDom(null);
@@ -1115,7 +1104,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlock(this.workspace);
parent.getInput('NAME').connection.setShadowDom(null);
@@ -1133,7 +1122,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlock(this.workspace);
parent.nextConnection.setShadowDom(null);
@@ -1152,7 +1141,7 @@ suite('Connection', function() {
);
});
});
suite('Add - Connect & Disconnect - Remove', function() {
// These are defined separately in each suite.
function createRowBlock(workspace) {
@@ -1161,21 +1150,21 @@ suite('Connection', function() {
), workspace);
return block;
}
function createStatementBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="statement_block"/>'
), workspace);
return block;
}
function createStackBlock(workspace) {
let block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<block type="stack_block"/>'
), workspace);
return block;
}
test('Value', function() {
let parent = createRowBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -1191,7 +1180,7 @@ suite('Connection', function() {
parent.getInput('INPUT').connection.setShadowDom(null);
assertInputNotHasBlock(parent, 'INPUT');
});
test('Multiple Value', function() {
let parent = createRowBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -1215,7 +1204,7 @@ suite('Connection', function() {
parent.getInput('INPUT').connection.setShadowDom(null);
assertInputNotHasBlock(parent, 'INPUT');
});
test('Statement', function() {
let parent = createStatementBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -1232,7 +1221,7 @@ suite('Connection', function() {
parent.getInput('NAME').connection.setShadowDom(null);
assertInputNotHasBlock(parent, 'NAME');
});
test('Multiple Statement', function() {
let parent = createStatementBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -1257,7 +1246,7 @@ suite('Connection', function() {
parent.getInput('NAME').connection.setShadowDom(null);
assertInputNotHasBlock(parent, 'NAME');
});
test('Next', function() {
let parent = createStackBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -1273,7 +1262,7 @@ suite('Connection', function() {
parent.nextConnection.setShadowDom(null);
assertNextNotHasBlock(parent);
});
test('Multiple Next', function() {
let parent = createStackBlock(this.workspace);
let xml = Blockly.Xml.textToDom(
@@ -1355,12 +1344,12 @@ suite('Connection', function() {
return Blockly.serialization.blocks.append(
{'type': 'row_block', 'id': 'id0'}, workspace);
}
function createStatementBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'statement_block', 'id': 'id0'}, workspace);
}
function createStackBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'stack_block', 'id': 'id0'}, workspace);
@@ -1615,7 +1604,7 @@ suite('Connection', function() {
},
workspace);
}
function createStatementBlocks(workspace) {
return Blockly.serialization.blocks.append(
{
@@ -1632,7 +1621,7 @@ suite('Connection', function() {
},
workspace);
}
function createStackBlocks(workspace) {
return Blockly.serialization.blocks.append(
{
@@ -1647,7 +1636,7 @@ suite('Connection', function() {
},
workspace);
}
test('Value', function() {
let parent = createRowBlocks(this.workspace);
parent.getInput('INPUT').connection
@@ -1677,7 +1666,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Value', function() {
let parent = createRowBlocks(this.workspace);
parent.getInput('INPUT').connection.setShadowState(
@@ -1734,7 +1723,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlocks(this.workspace);
parent.getInput('NAME').connection
@@ -1764,7 +1753,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Statement', function() {
let parent = createStatementBlocks(this.workspace);
parent.getInput('NAME').connection.setShadowState(
@@ -1822,7 +1811,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlocks(this.workspace);
parent.nextConnection
@@ -1850,7 +1839,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Next', function() {
let parent = createStackBlocks(this.workspace);
parent.nextConnection.setShadowState(
@@ -1901,24 +1890,24 @@ suite('Connection', function() {
);
});
});
suite('Add - With Shadow Connected', function() {
// These are defined separately in each suite.
function createRowBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'row_block', 'id': 'id0'}, workspace);
}
function createStatementBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'statement_block', 'id': 'id0'}, workspace);
}
function createStackBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'stack_block', 'id': 'id0'}, workspace);
}
test('Value', function() {
let parent = createRowBlock(this.workspace);
parent.getInput('INPUT').connection
@@ -1949,7 +1938,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Value', function() {
let parent = createRowBlock(this.workspace);
parent.getInput('INPUT').connection.setShadowState(
@@ -2020,7 +2009,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlock(this.workspace);
parent.getInput('NAME').connection
@@ -2051,7 +2040,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Statement', function() {
let parent = createStatementBlock(this.workspace);
parent.getInput('NAME').connection.setShadowState(
@@ -2122,7 +2111,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlock(this.workspace);
parent.nextConnection
@@ -2151,7 +2140,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Multiple Next', function() {
let parent = createStackBlock(this.workspace);
parent.nextConnection.setShadowState(
@@ -2213,7 +2202,7 @@ suite('Connection', function() {
);
});
});
suite('Remove - No Block Connected', function() {
// These are defined separately in each suite.
function createRowBlocks(workspace) {
@@ -2232,7 +2221,7 @@ suite('Connection', function() {
},
workspace);
}
function createStatementBlocks(workspace) {
return Blockly.serialization.blocks.append(
{
@@ -2249,7 +2238,7 @@ suite('Connection', function() {
},
workspace);
}
function createStackBlocks(workspace) {
return Blockly.serialization.blocks.append(
{
@@ -2264,7 +2253,7 @@ suite('Connection', function() {
},
workspace);
}
test('Value', function() {
let parent = createRowBlocks(this.workspace);
parent.getInput('INPUT').connection.setShadowState(null);
@@ -2280,7 +2269,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlocks(this.workspace);
parent.getInput('NAME').connection.setShadowState(null);
@@ -2296,7 +2285,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlocks(this.workspace);
parent.nextConnection.setShadowState(null);
@@ -2313,7 +2302,7 @@ suite('Connection', function() {
);
});
});
suite('Remove - Block Connected', function() {
// These are defined separately in each suite.
function createRowBlocks(workspace) {
@@ -2336,7 +2325,7 @@ suite('Connection', function() {
},
workspace);
}
function createStatementBlocks(workspace) {
return Blockly.serialization.blocks.append(
{
@@ -2357,7 +2346,7 @@ suite('Connection', function() {
},
workspace);
}
function createStackBlocks(workspace) {
return Blockly.serialization.blocks.append(
{
@@ -2376,7 +2365,7 @@ suite('Connection', function() {
},
workspace);
}
test('Value', function() {
let parent = createRowBlocks(this.workspace);
parent.getInput('INPUT').connection.setShadowState(null);
@@ -2394,7 +2383,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Statement', function() {
let parent = createStatementBlocks(this.workspace);
parent.getInput('NAME').connection.setShadowState(null);
@@ -2412,7 +2401,7 @@ suite('Connection', function() {
'</block>'
);
});
test('Next', function() {
let parent = createStackBlocks(this.workspace);
parent.nextConnection.setShadowState(null);
@@ -2431,24 +2420,24 @@ suite('Connection', function() {
);
});
});
suite('Add - Connect & Disconnect - Remove', function() {
// These are defined separately in each suite.
function createRowBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'row_block'}, workspace);
}
function createStatementBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'statement_block'}, workspace);
}
function createStackBlock(workspace) {
return Blockly.serialization.blocks.append(
{'type': 'stack_block'}, workspace);
}
test('Value', function() {
let parent = createRowBlock(this.workspace);
parent.getInput('INPUT').connection
@@ -2462,7 +2451,7 @@ suite('Connection', function() {
parent.getInput('INPUT').connection.setShadowState(null);
assertInputNotHasBlock(parent, 'INPUT');
});
test('Multiple Value', function() {
let parent = createRowBlock(this.workspace);
parent.getInput('INPUT').connection.setShadowState({
@@ -2488,7 +2477,7 @@ suite('Connection', function() {
parent.getInput('INPUT').connection.setShadowState(null);
assertInputNotHasBlock(parent, 'INPUT');
});
test('Statement', function() {
let parent = createStatementBlock(this.workspace);
parent.getInput('NAME').connection
@@ -2503,7 +2492,7 @@ suite('Connection', function() {
parent.getInput('NAME').connection.setShadowState(null);
assertInputNotHasBlock(parent, 'NAME');
});
test('Multiple Statement', function() {
let parent = createStatementBlock(this.workspace);
parent.getInput('NAME').connection.setShadowState({
@@ -2530,7 +2519,7 @@ suite('Connection', function() {
parent.getInput('NAME').connection.setShadowState(null);
assertInputNotHasBlock(parent, 'NAME');
});
test('Next', function() {
let parent = createStackBlock(this.workspace);
parent.nextConnection.setShadowState({'type': 'stack_block'});
@@ -2542,7 +2531,7 @@ suite('Connection', function() {
parent.nextConnection.setShadowState(null);
assertNextNotHasBlock(parent);
});
test('Multiple Next', function() {
let parent = createStackBlock(this.workspace);
parent.nextConnection.setShadowState({

View File

@@ -43,9 +43,10 @@ suite('Events', function() {
// Blockly.Event constructors, not the block constructors.
// Set the group id to avoid an extra call to genUid.
eventUtils.disable();
let block;
try {
eventUtils.setGroup('unused');
var block = new Blockly.Block(
block = new Blockly.Block(
workspace, 'simple_test_block');
} finally {
eventUtils.setGroup(false);
@@ -961,9 +962,10 @@ suite('Events', function() {
});
test('Block dispose triggers Delete', function() {
let workspaceSvg;
try {
let toolbox = document.getElementById('toolbox-categories');
var workspaceSvg = Blockly.inject('blocklyDiv', {toolbox: toolbox});
workspaceSvg = Blockly.inject('blocklyDiv', {toolbox: toolbox});
let TEST_BLOCK_ID = 'test_block_id';
let genUidStub = createGenUidStubWithReturns(
[TEST_BLOCK_ID, 'test_group_id']);

View File

@@ -208,7 +208,7 @@ suite('InsertionMarkers', function() {
Blockly.Xml.domToWorkspace(xml, this.workspace);
let block = this.workspace.getBlockById('insertion');
block.setInsertionMarker(true);
var xml = Blockly.Xml.workspaceToDom(this.workspace);
let xml = Blockly.Xml.workspaceToDom(this.workspace);
Blockly.Xml.domToWorkspace(xml, this.workspace);
xml = Blockly.Xml.domToText(xml);
chai.assert.equal(xml, expectXml);

View File

@@ -141,14 +141,14 @@ suite('JSON Block Definitions', function() {
chai.assert.equal(block.inputList.length, 2);
chai.assert.equal(block.inputList[0].fieldRow.length, 1);
var textField = block.inputList[0].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, textField.constructor);
chai.assert.equal(MESSAGE0, textField.getText());
const firstTextField = block.inputList[0].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, firstTextField.constructor);
chai.assert.equal(MESSAGE0, firstTextField.getText());
chai.assert.equal(block.inputList[1].fieldRow.length, 1);
var textField = block.inputList[1].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, textField.constructor);
chai.assert.equal(MESSAGE1, textField.getText());
const secondTextField = block.inputList[1].fieldRow[0];
chai.assert.equal(Blockly.FieldLabel, secondTextField.constructor);
chai.assert.equal(MESSAGE1, secondTextField.getText());
});
test('Message string is dereferenced', function() {

View File

@@ -139,7 +139,7 @@ suite('Procedures', function() {
test('Nested caller', function() {
this.barDef.setEnabled(false);
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.isFalse(this.barCalls[i].isEnabled(),
'Callers are disabled when their definition is disabled ' +
'(bar call ' + i + ')');
@@ -151,7 +151,7 @@ suite('Procedures', function() {
this.fooDef.setEnabled(false);
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.isFalse(this.fooCalls[i].isEnabled(),
'Callers are disabled when their definition is disabled ' +
'(foo call ' + i + ')');
@@ -159,7 +159,7 @@ suite('Procedures', function() {
this.barDef.setEnabled(true);
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.isTrue(this.barCalls[i].isEnabled(),
'Callers are reenabled with their definition ' +
'(bar call ' + i + ')');
@@ -747,7 +747,7 @@ suite('Procedures', function() {
this.barDef.setEnabled(false);
Blockly.Events.setGroup(false);
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.isFalse(this.barCalls[i].isEnabled(),
'Callers are disabled when their definition is disabled (call ' +
i + ')');
@@ -755,7 +755,7 @@ suite('Procedures', function() {
let firedEvents = this.workspaceSvg.undoStack_;
chai.assert.equal(firedEvents.length, 3,
'An event was fired for the definition and each caller');
for (var i = 0; i < 3; i++) {
for (let i = 0; i < 3; i++) {
chai.assert.equal(firedEvents[i].group, 'g1',
'Disable events are in the same group (event ' + i + ')');
}
@@ -765,14 +765,14 @@ suite('Procedures', function() {
this.barDef.setEnabled(true);
Blockly.Events.setGroup(false);
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.isTrue(this.barCalls[i].isEnabled(),
'Callers are enabled when their definition is enabled (call ' +
i + ')');
}
chai.assert.equal(firedEvents.length, 3,
'An event was fired for the definition and each caller');
for (var i = 0; i < 3; i++) {
for (let i = 0; i < 3; i++) {
chai.assert.equal(firedEvents[i].group, 'g2',
'Enable events are in the same group (event ' + i + ')');
}
@@ -784,7 +784,7 @@ suite('Procedures', function() {
this.barDef.setEnabled(false);
Blockly.Events.setGroup(false);
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.isFalse(this.barCalls[i].isEnabled(),
'Callers are disabled when their definition is disabled (call ' +
i + ')');
@@ -792,7 +792,7 @@ suite('Procedures', function() {
let firedEvents = this.workspaceSvg.undoStack_;
chai.assert.equal(firedEvents.length, 2,
'An event was fired for the definition and the enabled caller');
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.equal(firedEvents[i].group, 'g1',
'Disable events are in the same group (event ' + i + ')');
}
@@ -808,7 +808,7 @@ suite('Procedures', function() {
'Caller returns to previous enabled state when the definition is enabled');
chai.assert.equal(firedEvents.length, 2,
'An event was fired for the definition and the enabled caller');
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
chai.assert.equal(firedEvents[i].group, 'g2',
'Enable events are in the same group (event ' + i + ')');
}
@@ -889,11 +889,11 @@ suite('Procedures', function() {
}
function assertArgs(argArray) {
chai.assert.equal(this.defBlock.arguments_.length, argArray.length);
for (var i = 0; i < argArray.length; i++) {
for (let i = 0; i < argArray.length; i++) {
chai.assert.equal(this.defBlock.arguments_[i], argArray[i]);
}
chai.assert.equal(this.callBlock.arguments_.length, argArray.length);
for (var i = 0; i < argArray.length; i++) {
for (let i = 0; i < argArray.length; i++) {
chai.assert.equal(this.callBlock.arguments_[i], argArray[i]);
}
}

View File

@@ -117,10 +117,11 @@ suite('Theme', function() {
test('Set Theme', function() {
defineThemeTestBlocks();
let workspace;
try {
let blockStyles = createBlockStyles();
let theme = new Blockly.Theme('themeName', blockStyles);
var workspace = new Blockly.WorkspaceSvg(new Blockly.Options({}));
workspace = new Blockly.WorkspaceSvg(new Blockly.Options({}));
let blockA = workspace.newBlock('stack_block');
blockA.setStyle = function() {this.styleName_ = 'styleTwo';};

View File

@@ -407,7 +407,7 @@ suite('Toolbox', function() {
function testHideFlyout(toolbox, oldItem, newItem) {
let updateFlyoutStub = sinon.stub(toolbox.flyout_, 'hide');
var newItem = getNonCollapsibleItem(toolbox);
const newItem = getNonCollapsibleItem(toolbox);
toolbox.updateFlyout_(oldItem, newItem);
sinon.assert.called(updateFlyoutStub);
}

View File

@@ -49,7 +49,7 @@ function testAWorkspace() {
let blocks = [];
// Turn off events to avoid testing XML at the same time.
eventUtils.disable();
for (var i = 0, id; (id = ids[i]); i++) {
for (let i = 0, id; (id = ids[i]); i++) {
let block = new Blockly.Block(workspace, 'get_var_block');
block.inputList[0].fieldRow[0].setValue(id);
blocks.push(block);
@@ -644,7 +644,7 @@ function testAWorkspace() {
let expectedString = '\n' + Blockly.Xml.domToPrettyText(expected) + '\n';
chai.assert.equal(actual.tagName, expected.tagName);
for (var i = 0, attr; (attr = expected.attributes[i]); i++) {
for (let i = 0, attr; (attr = expected.attributes[i]); i++) {
chai.assert.equal(actual.getAttribute(attr.name), attr.value,
`expected attribute ${attr.name} on ${actualString} to match ` +
`${expectedString}`);
@@ -652,7 +652,7 @@ function testAWorkspace() {
chai.assert.equal(actual.childElementCount, expected.childElementCount,
`expected node ${actualString} to have the same children as node ` +
`${expectedString}`);
for (var i = 0; i < expected.childElementCount; i++) {
for (let i = 0; i < expected.childElementCount; i++) {
assertNodesEqual(actual.children[i], expected.children[i]);
}
}

View File

@@ -460,7 +460,7 @@ suite('XML', function() {
this.workspace.createVariable('name1', '', 'id1');
let blocksArray =
Blockly.Variables.flyoutCategoryBlocks(this.workspace);
for (var i = 0, xml; (xml = blocksArray[i]); i++) {
for (let i = 0, xml; (xml = blocksArray[i]); i++) {
Blockly.Xml.domToBlock(xml, this.workspace);
}
});
@@ -470,7 +470,7 @@ suite('XML', function() {
this.workspace.createVariable('name3', 'Colour', 'id3');
let blocksArray =
Blockly.VariablesDynamic.flyoutCategoryBlocks(this.workspace);
for (var i = 0, xml; (xml = blocksArray[i]); i++) {
for (let i = 0, xml; (xml = blocksArray[i]); i++) {
Blockly.Xml.domToBlock(xml, this.workspace);
}
});
@@ -764,7 +764,7 @@ suite('XML', function() {
block.commentModel.pinned = true;
this.clock.runAll();
assertRoundTrip(this.headlessWorkspace, this.renderedWorkspace);
});
});