chore: apply prefer-const rule fixes in mocha tests (#5682)

This commit is contained in:
Rachel Fenichel
2021-11-05 14:25:33 -07:00
committed by GitHub
parent 6448528e9a
commit 1ebec55393
58 changed files with 2147 additions and 2146 deletions

View File

@@ -57,7 +57,7 @@ suite('Events', function() {
suite('Constructors', function() {
test('Abstract', function() {
let event = new Blockly.Events.Abstract();
const event = new Blockly.Events.Abstract();
assertEventEquals(event, undefined, undefined, undefined, {
'recordUndo': true,
'group': ''
@@ -65,7 +65,7 @@ suite('Events', function() {
});
test('UI event without block', function() {
let event = new Blockly.Events.UiBase(this.workspace.id);
const event = new Blockly.Events.UiBase(this.workspace.id);
assertEventEquals(event, undefined, this.workspace.id, undefined, {
'recordUndo': false,
'group': '',
@@ -73,7 +73,7 @@ suite('Events', function() {
});
test('Click without block', function() {
let event = new Blockly.Events.Click(null, this.workspace.id, 'workspace');
const event = new Blockly.Events.Click(null, this.workspace.id, 'workspace');
assertEventEquals(event, Blockly.Events.CLICK, this.workspace.id, null, {
'targetType': 'workspace',
'recordUndo': false,
@@ -82,9 +82,9 @@ suite('Events', function() {
});
test('Old UI event without block', function() {
let TEST_GROUP_ID = 'testGroup';
const TEST_GROUP_ID = 'testGroup';
eventUtils.setGroup(TEST_GROUP_ID);
let event = new Blockly.Events.Ui(null, 'foo', 'bar', 'baz');
const event = new Blockly.Events.Ui(null, 'foo', 'bar', 'baz');
assertEventEquals(event, Blockly.Events.UI, '', null, {
'element': 'foo',
'oldValue': 'bar',
@@ -105,7 +105,7 @@ suite('Events', function() {
});
test('Block base', function() {
let event = new Blockly.Events.BlockBase(this.block);
const event = new Blockly.Events.BlockBase(this.block);
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, undefined,
this.workspace.id, this.TEST_BLOCK_ID,
@@ -117,7 +117,7 @@ suite('Events', function() {
});
test('Block create', function() {
let event = new Blockly.Events.BlockCreate(this.block);
const event = new Blockly.Events.BlockCreate(this.block);
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_CREATE,
this.workspace.id, this.TEST_BLOCK_ID,
@@ -128,7 +128,7 @@ suite('Events', function() {
});
test('Block delete', function() {
let event = new Blockly.Events.BlockDelete(this.block);
const event = new Blockly.Events.BlockDelete(this.block);
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_DELETE,
this.workspace.id, this.TEST_BLOCK_ID,
@@ -139,9 +139,9 @@ suite('Events', function() {
});
test('Old UI event with block', function() {
let TEST_GROUP_ID = 'testGroup';
const TEST_GROUP_ID = 'testGroup';
eventUtils.setGroup(TEST_GROUP_ID);
let event = new Blockly.Events.Ui(this.block, 'foo', 'bar', 'baz');
const event = new Blockly.Events.Ui(this.block, 'foo', 'bar', 'baz');
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, Blockly.Events.UI, this.workspace.id,
this.TEST_BLOCK_ID,
@@ -155,9 +155,9 @@ suite('Events', function() {
});
test('Click with block', function() {
let TEST_GROUP_ID = 'testGroup';
const TEST_GROUP_ID = 'testGroup';
eventUtils.setGroup(TEST_GROUP_ID);
let event = new Blockly.Events.Click(this.block, null, 'block');
const event = new Blockly.Events.Click(this.block, null, 'block');
assertEventEquals(event, Blockly.Events.CLICK, this.workspace.id,
this.TEST_BLOCK_ID, {
'targetType': 'block',
@@ -168,10 +168,10 @@ suite('Events', function() {
suite('Block Move', function() {
test('by coordinate', function() {
let coordinate = new Blockly.utils.Coordinate(3, 4);
const coordinate = new Blockly.utils.Coordinate(3, 4);
this.block.xy_ = coordinate;
let event = new Blockly.Events.BlockMove(this.block);
const event = new Blockly.Events.BlockMove(this.block);
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_MOVE, this.workspace.id,
this.TEST_BLOCK_ID, {
@@ -188,7 +188,7 @@ suite('Events', function() {
this.parentBlock = createSimpleTestBlock(this.workspace);
this.block.parentBlock_ = this.parentBlock;
this.block.xy_ = new Blockly.utils.Coordinate(3, 4);
let event = new Blockly.Events.BlockMove(this.block);
const event = new Blockly.Events.BlockMove(this.block);
sinon.assert.calledTwice(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_MOVE, this.workspace.id,
this.TEST_BLOCK_ID, {
@@ -218,7 +218,7 @@ suite('Events', function() {
});
test('Block base', function() {
let event = new Blockly.Events.BlockBase(this.block);
const event = new Blockly.Events.BlockBase(this.block);
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, undefined,
this.workspace.id, this.TEST_BLOCK_ID,
@@ -230,7 +230,7 @@ suite('Events', function() {
});
test('Block change', function() {
let event = new Blockly.Events.BlockChange(
const event = new Blockly.Events.BlockChange(
this.block, 'field', 'FIELD_NAME', 'old', 'new');
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_CHANGE,
@@ -247,7 +247,7 @@ suite('Events', function() {
});
test('Block create', function() {
let event = new Blockly.Events.BlockCreate(this.block);
const event = new Blockly.Events.BlockCreate(this.block);
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_CREATE,
this.workspace.id, this.TEST_BLOCK_ID,
@@ -258,7 +258,7 @@ suite('Events', function() {
});
test('Block delete', function() {
let event = new Blockly.Events.BlockDelete(this.block);
const event = new Blockly.Events.BlockDelete(this.block);
sinon.assert.calledOnce(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_DELETE,
this.workspace.id, this.TEST_BLOCK_ID,
@@ -273,7 +273,7 @@ suite('Events', function() {
this.parentBlock = createSimpleTestBlock(this.workspace);
this.block.parentBlock_ = this.parentBlock;
this.block.xy_ = new Blockly.utils.Coordinate(3, 4);
let event = new Blockly.Events.BlockMove(this.block);
const event = new Blockly.Events.BlockMove(this.block);
sinon.assert.calledTwice(this.genUidStub);
assertEventEquals(event, Blockly.Events.BLOCK_MOVE, this.workspace.id,
this.TEST_BLOCK_ID,
@@ -302,7 +302,7 @@ suite('Events', function() {
});
test('Block change', function() {
let event = new Blockly.Events.BlockChange(
const event = new Blockly.Events.BlockChange(
this.block, 'field', 'VAR', 'id1', 'id2');
assertEventEquals(event, Blockly.Events.BLOCK_CHANGE, this.workspace.id,
this.TEST_BLOCK_ID,
@@ -319,8 +319,8 @@ suite('Events', function() {
});
suite('Serialization', function() {
let safeStringify = (json) => {
let cache = [];
const safeStringify = (json) => {
const cache = [];
return JSON.stringify(json, (key, value) => {
if (typeof value == 'object' && value != null) {
if (cache.includes(value)) {
@@ -333,7 +333,7 @@ suite('Events', function() {
return value;
});
};
let variableEventTestCases = [
const variableEventTestCases = [
{title: 'Var create', class: Blockly.Events.VarCreate,
getArgs: (thisObj) => [thisObj.variable],
getExpectedJson: () => ({type: 'var_create', varId: 'id1',
@@ -347,7 +347,7 @@ suite('Events', function() {
getExpectedJson: () => ({type: 'var_rename', varId: 'id1',
oldName: 'name1', newName: 'name2'})},
];
let uiEventTestCases = [
const uiEventTestCases = [
{title: 'Bubble open', class: Blockly.Events.BubbleOpen,
getArgs: (thisObj) => [thisObj.block, true, 'mutator'],
getExpectedJson: (thisObj) => ({type: 'bubble_open', isOpen: true,
@@ -439,7 +439,7 @@ suite('Events', function() {
getExpectedJson: () => ({type: 'viewport_change', viewTop: 0,
viewLeft: 0, scale: 1.2, oldScale: 1})},
];
let blockEventTestCases = [
const blockEventTestCases = [
{
title: 'Block change',
class: Blockly.Events.BlockChange,
@@ -553,13 +553,13 @@ suite('Events', function() {
})
},
];
let workspaceEventTestCases = [
const workspaceEventTestCases = [
{title: 'Finished Loading', class: Blockly.Events.FinishedLoading,
getArgs: (thisObj) => [thisObj.workspace],
getExpectedJson: (thisObj) => ({type: 'finished_loading',
workspaceId: thisObj.workspace.id})},
];
let workspaceCommentEventTestCases = [
const workspaceCommentEventTestCases = [
{title: 'Comment change', class: Blockly.Events.CommentChange,
getArgs: (thisObj) => [thisObj.comment, 'bar', 'foo'],
getExpectedJson: (thisObj) => ({type: 'comment_change',
@@ -580,7 +580,7 @@ suite('Events', function() {
getExpectedJson: (thisObj) => ({type: 'comment_move',
commentId: thisObj.comment.id, oldCoordinate: '0,0'})},
];
let testSuites = [
const testSuites = [
{title: 'Variable events', testCases: variableEventTestCases,
setup: (thisObj) => {
thisObj.variable =
@@ -615,9 +615,9 @@ suite('Events', function() {
suite('fromJson', function() {
testSuite.testCases.forEach((testCase) => {
test(testCase.title, function() {
let event = new testCase.class(...testCase.getArgs(this));
let event2 = new testCase.class();
let json = event.toJson();
const event = new testCase.class(...testCase.getArgs(this));
const event2 = new testCase.class();
const json = event.toJson();
event2.fromJson(json);
chai.assert.equal(
@@ -629,9 +629,9 @@ suite('Events', function() {
testSuite.testCases.forEach((testCase) => {
if (testCase.getExpectedJson) {
test(testCase.title, function() {
let event = new testCase.class(...testCase.getArgs(this));
let json = event.toJson();
let expectedJson = testCase.getExpectedJson(this);
const event = new testCase.class(...testCase.getArgs(this));
const json = event.toJson();
const expectedJson = testCase.getExpectedJson(this);
chai.assert.equal(
safeStringify(json), safeStringify(expectedJson));
@@ -657,7 +657,7 @@ suite('Events', function() {
* @param {!string} id The expected id of the variable.
*/
function checkVariableValues(container, name, type, id) {
let variable = container.getVariableById(id);
const variable = container.getVariableById(id);
chai.assert.isDefined(variable);
chai.assert.equal(name, variable.name);
chai.assert.equal(type, variable.type);
@@ -666,7 +666,7 @@ suite('Events', function() {
suite('Constructors', function() {
test('Var base', function() {
let event = new Blockly.Events.VarBase(this.variable);
const event = new Blockly.Events.VarBase(this.variable);
assertEventEquals(event, undefined, this.workspace.id, undefined, {
'varId': 'id1',
'recordUndo': true,
@@ -675,7 +675,7 @@ suite('Events', function() {
});
test('Var create', function() {
let event = new Blockly.Events.VarCreate(this.variable);
const event = new Blockly.Events.VarCreate(this.variable);
assertEventEquals(event, Blockly.Events.VAR_CREATE, this.workspace.id,
undefined,
{
@@ -688,7 +688,7 @@ suite('Events', function() {
});
test('Var delete', function() {
let event = new Blockly.Events.VarDelete(this.variable);
const event = new Blockly.Events.VarDelete(this.variable);
assertEventEquals(event, Blockly.Events.VAR_DELETE, this.workspace.id,
undefined,
{
@@ -701,7 +701,7 @@ suite('Events', function() {
});
test('Var rename', function() {
let event = new Blockly.Events.VarRename(this.variable, 'name2');
const event = new Blockly.Events.VarRename(this.variable, 'name2');
assertEventEquals(event, Blockly.Events.VAR_RENAME, this.workspace.id,
undefined,
{
@@ -716,24 +716,24 @@ suite('Events', function() {
suite('Run Forward', function() {
test('Var create', function() {
let json = {type: "var_create", varId: "id2", varType: "type2",
const json = {type: "var_create", varId: "id2", varType: "type2",
varName: "name2"};
let event = eventUtils.fromJson(json, this.workspace);
let x = this.workspace.getVariableById('id2');
const event = eventUtils.fromJson(json, this.workspace);
const x = this.workspace.getVariableById('id2');
chai.assert.isNull(x);
event.run(true);
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
});
test('Var delete', function() {
let event = new Blockly.Events.VarDelete(this.variable);
const event = new Blockly.Events.VarDelete(this.variable);
chai.assert.isNotNull(this.workspace.getVariableById('id1'));
event.run(true);
chai.assert.isNull(this.workspace.getVariableById('id1'));
});
test('Var rename', function() {
let event = new Blockly.Events.VarRename(this.variable, 'name2');
const event = new Blockly.Events.VarRename(this.variable, 'name2');
event.run(true);
chai.assert.isNull(this.workspace.getVariable('name1'));
checkVariableValues(this.workspace, 'name2', 'type1', 'id1');
@@ -741,22 +741,22 @@ suite('Events', function() {
});
suite('Run Backward', function() {
test('Var create', function() {
let event = new Blockly.Events.VarCreate(this.variable);
const event = new Blockly.Events.VarCreate(this.variable);
chai.assert.isNotNull(this.workspace.getVariableById('id1'));
event.run(false);
});
test('Var delete', function() {
let json = {type: "var_delete", varId: "id2", varType: "type2",
const json = {type: "var_delete", varId: "id2", varType: "type2",
varName: "name2"};
let event = eventUtils.fromJson(json, this.workspace);
const event = eventUtils.fromJson(json, this.workspace);
chai.assert.isNull(this.workspace.getVariableById('id2'));
event.run(false);
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
});
test('Var rename', function() {
let event = new Blockly.Events.VarRename(this.variable, 'name2');
const event = new Blockly.Events.VarRename(this.variable, 'name2');
event.run(false);
chai.assert.isNull(this.workspace.getVariable('name2'));
checkVariableValues(this.workspace, 'name1', 'type1', 'id1');
@@ -778,14 +778,14 @@ suite('Events', function() {
}
test('No removed, order unchanged', function() {
let block = this.workspace.newBlock('field_variable_test_block', '1');
let events = [
const block = this.workspace.newBlock('field_variable_test_block', '1');
const events = [
new Blockly.Events.BlockCreate(block),
new Blockly.Events.BlockMove(block),
new Blockly.Events.BlockChange(block, 'field', 'VAR', 'id1', 'id2'),
new Blockly.Events.Click(block)
];
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
chai.assert.equal(filteredEvents.length, 4); // no event should have been removed.
// test that the order hasn't changed
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
@@ -795,25 +795,25 @@ suite('Events', function() {
});
test('Different blocks no removed', function() {
let block1 = this.workspace.newBlock('field_variable_test_block', '1');
let block2 = this.workspace.newBlock('field_variable_test_block', '2');
let events = [
const block1 = this.workspace.newBlock('field_variable_test_block', '1');
const block2 = this.workspace.newBlock('field_variable_test_block', '2');
const events = [
new Blockly.Events.BlockCreate(block1),
new Blockly.Events.BlockMove(block1),
new Blockly.Events.BlockCreate(block2),
new Blockly.Events.BlockMove(block2)
];
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
chai.assert.equal(filteredEvents.length, 4); // no event should have been removed.
});
test('Forward', function() {
let block = this.workspace.newBlock('field_variable_test_block', '1');
let events = [ new Blockly.Events.BlockCreate(block) ];
const block = this.workspace.newBlock('field_variable_test_block', '1');
const events = [ new Blockly.Events.BlockCreate(block) ];
addMoveEvent(events, block, 1, 1);
addMoveEvent(events, block, 2, 2);
addMoveEvent(events, block, 3, 3);
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
chai.assert.equal(filteredEvents.length, 2); // duplicate moves should have been removed.
// test that the order hasn't changed
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
@@ -823,12 +823,12 @@ suite('Events', function() {
});
test('Backward', function() {
let block = this.workspace.newBlock('field_variable_test_block', '1');
let events = [ new Blockly.Events.BlockCreate(block) ];
const block = this.workspace.newBlock('field_variable_test_block', '1');
const events = [ new Blockly.Events.BlockCreate(block) ];
addMoveEvent(events, block, 1, 1);
addMoveEvent(events, block, 2, 2);
addMoveEvent(events, block, 3, 3);
let filteredEvents = eventUtils.filter(events, false);
const filteredEvents = eventUtils.filter(events, false);
chai.assert.equal(filteredEvents.length, 2); // duplicate event should have been removed.
// test that the order hasn't changed
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
@@ -838,34 +838,34 @@ suite('Events', function() {
});
test('Merge block move events', function() {
let block = this.workspace.newBlock('field_variable_test_block', '1');
let events = [];
const block = this.workspace.newBlock('field_variable_test_block', '1');
const events = [];
addMoveEvent(events, block, 0, 0);
addMoveEvent(events, block, 1, 1);
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
chai.assert.equal(filteredEvents.length, 1); // second move event merged into first
chai.assert.equal(filteredEvents[0].newCoordinate.x, 1);
chai.assert.equal(filteredEvents[0].newCoordinate.y, 1);
});
test('Merge block change events', function() {
let block1 = this.workspace.newBlock('field_variable_test_block', '1');
let events = [
const block1 = this.workspace.newBlock('field_variable_test_block', '1');
const events = [
new Blockly.Events.BlockChange(block1, 'field', 'VAR', 'item', 'item1'),
new Blockly.Events.BlockChange(block1, 'field', 'VAR', 'item1', 'item2')
];
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
chai.assert.equal(filteredEvents.length, 1); // second change event merged into first
chai.assert.equal(filteredEvents[0].oldValue, 'item');
chai.assert.equal(filteredEvents[0].newValue, 'item2');
});
test('Merge viewport change events', function() {
let events = [
const events = [
new Blockly.Events.ViewportChange(1, 2, 3, this.workspace, 4),
new Blockly.Events.ViewportChange(5, 6, 7, this.workspace, 8)
];
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
chai.assert.equal(filteredEvents.length, 1); // second change event merged into first
chai.assert.equal(filteredEvents[0].viewTop, 5);
chai.assert.equal(filteredEvents[0].viewLeft, 6);
@@ -874,10 +874,10 @@ suite('Events', function() {
});
test('Merge ui events', function() {
let block1 = this.workspace.newBlock('field_variable_test_block', '1');
let block2 = this.workspace.newBlock('field_variable_test_block', '2');
let block3 = this.workspace.newBlock('field_variable_test_block', '3');
let events = [
const block1 = this.workspace.newBlock('field_variable_test_block', '1');
const block2 = this.workspace.newBlock('field_variable_test_block', '2');
const block3 = this.workspace.newBlock('field_variable_test_block', '3');
const events = [
new Blockly.Events.BubbleOpen(block1, true, 'comment'),
new Blockly.Events.Click(block1),
new Blockly.Events.BubbleOpen(block2, true, 'mutator'),
@@ -885,7 +885,7 @@ suite('Events', function() {
new Blockly.Events.BubbleOpen(block3, true, 'warning'),
new Blockly.Events.Click(block3)
];
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
// click event merged into corresponding *Open event
chai.assert.equal(filteredEvents.length, 3);
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BubbleOpen);
@@ -899,12 +899,12 @@ suite('Events', function() {
test('Colliding events not dropped', function() {
// Tests that events that collide on a (event, block, workspace) tuple
// but cannot be merged do not get dropped during filtering.
let block = this.workspace.newBlock('field_variable_test_block', '1');
let events = [
const block = this.workspace.newBlock('field_variable_test_block', '1');
const events = [
new Blockly.Events.Click(block),
new Blockly.Events.Ui(block, 'stackclick', undefined, undefined)
];
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
// click and stackclick should both exist
chai.assert.equal(filteredEvents.length, 2);
chai.assert.isTrue(filteredEvents[0] instanceof Blockly.Events.Click);
@@ -919,12 +919,12 @@ suite('Events', function() {
// that two move events that do get merged (disconnecting and
// reconnecting a block in response to a mutator change) are filtered
// from the queue.
let block = this.workspace.newBlock('field_variable_test_block', '1');
const block = this.workspace.newBlock('field_variable_test_block', '1');
block.setParent(null);
let events = [];
const events = [];
addMoveEventParent(events, block, null);
addMoveEventParent(events, block, null);
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
// The two events should be merged, but because nothing has changed
// they will be filtered out.
chai.assert.equal(filteredEvents.length, 0);
@@ -936,16 +936,16 @@ suite('Events', function() {
// See github.com/google/blockly/pull/1892 for a worked example showing
// how merging non-consecutive events can fail when replacing a shadow
// block.
let block1 = createSimpleTestBlock(this.workspace);
let block2 = createSimpleTestBlock(this.workspace);
const block1 = createSimpleTestBlock(this.workspace);
const block2 = createSimpleTestBlock(this.workspace);
let events = [];
const events = [];
addMoveEvent(events, block1, 1, 1);
addMoveEvent(events, block2, 1, 1);
events.push(new Blockly.Events.BlockDelete(block2));
addMoveEvent(events, block1, 2, 2);
let filteredEvents = eventUtils.filter(events, true);
const filteredEvents = eventUtils.filter(events, true);
// Nothing should have merged.
chai.assert.equal(filteredEvents.length, 4);
// test that the order hasn't changed
@@ -964,23 +964,23 @@ suite('Events', function() {
test('Block dispose triggers Delete', function() {
let workspaceSvg;
try {
let toolbox = document.getElementById('toolbox-categories');
const toolbox = document.getElementById('toolbox-categories');
workspaceSvg = Blockly.inject('blocklyDiv', {toolbox: toolbox});
let TEST_BLOCK_ID = 'test_block_id';
let genUidStub = createGenUidStubWithReturns(
const TEST_BLOCK_ID = 'test_block_id';
const genUidStub = createGenUidStubWithReturns(
[TEST_BLOCK_ID, 'test_group_id']);
let block = workspaceSvg.newBlock('');
const block = workspaceSvg.newBlock('');
block.initSvg();
block.setCommentText('test comment');
let expectedOldXml = Blockly.Xml.blockToDomWithXY(block);
let expectedId = block.id;
const expectedOldXml = Blockly.Xml.blockToDomWithXY(block);
const expectedId = block.id;
// Run all queued events.
this.clock.runAll();
this.eventsFireSpy.resetHistory();
let changeListenerSpy = createFireChangeListenerSpy(workspaceSvg);
const changeListenerSpy = createFireChangeListenerSpy(workspaceSvg);
block.dispose();
// Run all queued events.
@@ -1007,13 +1007,13 @@ suite('Events', function() {
});
test('New block new var', function() {
let TEST_BLOCK_ID = 'test_block_id';
let TEST_GROUP_ID = 'test_group_id';
let TEST_VAR_ID = 'test_var_id';
let genUidStub = createGenUidStubWithReturns(
const TEST_BLOCK_ID = 'test_block_id';
const TEST_GROUP_ID = 'test_group_id';
const TEST_VAR_ID = 'test_var_id';
const genUidStub = createGenUidStubWithReturns(
[TEST_BLOCK_ID, TEST_GROUP_ID, TEST_VAR_ID]);
let _ = this.workspace.newBlock('field_variable_test_block');
let TEST_VAR_NAME = 'item'; // As defined in block's json.
const _ = this.workspace.newBlock('field_variable_test_block');
const TEST_VAR_NAME = 'item'; // As defined in block's json.
// Run all queued events.
this.clock.runAll();
@@ -1043,18 +1043,18 @@ suite('Events', function() {
});
test('New block new var xml', function() {
let TEST_GROUP_ID = 'test_group_id';
let genUidStub = createGenUidStubWithReturns(TEST_GROUP_ID);
let dom = Blockly.Xml.textToDom(
const TEST_GROUP_ID = 'test_group_id';
const genUidStub = createGenUidStubWithReturns(TEST_GROUP_ID);
const dom = Blockly.Xml.textToDom(
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="field_variable_test_block" id="test_block_id">' +
' <field name="VAR" id="test_var_id">name1</field>' +
' </block>' +
'</xml>');
Blockly.Xml.domToWorkspace(dom, this.workspace);
let TEST_BLOCK_ID = 'test_block_id';
let TEST_VAR_ID = 'test_var_id';
let TEST_VAR_NAME = 'name1';
const TEST_BLOCK_ID = 'test_block_id';
const TEST_VAR_ID = 'test_var_id';
const TEST_VAR_NAME = 'name1';
// Run all queued events.
this.clock.runAll();
@@ -1095,7 +1095,7 @@ suite('Events', function() {
suite('Disable orphans', function() {
setup(function() {
// disableOrphans needs a WorkspaceSVG
let toolbox = document.getElementById('toolbox-categories');
const toolbox = document.getElementById('toolbox-categories');
this.workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});
});
teardown(function() {
@@ -1103,7 +1103,7 @@ suite('Events', function() {
});
test('Created orphan block is disabled', function() {
this.workspace.addChangeListener(eventUtils.disableOrphans);
let block = this.workspace.newBlock('controls_for');
const block = this.workspace.newBlock('controls_for');
block.initSvg();
block.render();
@@ -1117,7 +1117,7 @@ suite('Events', function() {
this.workspace.addChangeListener(eventUtils.disableOrphans);
// Procedure block is never an orphan
let functionBlock = this.workspace.newBlock('procedures_defnoreturn');
const functionBlock = this.workspace.newBlock('procedures_defnoreturn');
functionBlock.initSvg();
functionBlock.render();
@@ -1129,11 +1129,11 @@ suite('Events', function() {
});
test('Moving a block to top-level disables it', function() {
this.workspace.addChangeListener(eventUtils.disableOrphans);
let functionBlock = this.workspace.newBlock('procedures_defnoreturn');
const functionBlock = this.workspace.newBlock('procedures_defnoreturn');
functionBlock.initSvg();
functionBlock.render();
let block = this.workspace.newBlock('controls_for');
const block = this.workspace.newBlock('controls_for');
block.initSvg();
block.render();
@@ -1151,11 +1151,11 @@ suite('Events', function() {
});
test('Giving block a parent enables it', function() {
this.workspace.addChangeListener(eventUtils.disableOrphans);
let functionBlock = this.workspace.newBlock('procedures_defnoreturn');
const functionBlock = this.workspace.newBlock('procedures_defnoreturn');
functionBlock.initSvg();
functionBlock.render();
let block = this.workspace.newBlock('controls_for');
const block = this.workspace.newBlock('controls_for');
block.initSvg();
block.render();
@@ -1170,11 +1170,11 @@ suite('Events', function() {
});
test('disableOrphans events are not undoable', function() {
this.workspace.addChangeListener(eventUtils.disableOrphans);
let functionBlock = this.workspace.newBlock('procedures_defnoreturn');
const functionBlock = this.workspace.newBlock('procedures_defnoreturn');
functionBlock.initSvg();
functionBlock.render();
let block = this.workspace.newBlock('controls_for');
const block = this.workspace.newBlock('controls_for');
block.initSvg();
block.render();
@@ -1187,7 +1187,7 @@ suite('Events', function() {
// Fire all events
this.clock.runAll();
let disabledEvents = this.workspace.getUndoStack().filter(function(e) {
const disabledEvents = this.workspace.getUndoStack().filter(function(e) {
return e.element === 'disabled';
});
chai.assert.isEmpty(disabledEvents,