mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
fix!: remove deprecated setEnabled and backwards event filtering (#9039)
This commit is contained in:
@@ -1222,7 +1222,7 @@ suite('Events', function () {
|
||||
new Blockly.Events.BlockChange(block, 'field', 'VAR', 'id1', 'id2'),
|
||||
new Blockly.Events.Click(block),
|
||||
];
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
assert.equal(filteredEvents.length, 4); // no event should have been removed.
|
||||
// test that the order hasn't changed
|
||||
assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
|
||||
@@ -1240,7 +1240,7 @@ suite('Events', function () {
|
||||
new Blockly.Events.BlockCreate(block2),
|
||||
new Blockly.Events.BlockMove(block2),
|
||||
];
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
assert.equal(filteredEvents.length, 4); // no event should have been removed.
|
||||
});
|
||||
|
||||
@@ -1250,7 +1250,7 @@ suite('Events', function () {
|
||||
addMoveEvent(events, block, 1, 1);
|
||||
addMoveEvent(events, block, 2, 2);
|
||||
addMoveEvent(events, block, 3, 3);
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
assert.equal(filteredEvents.length, 2); // duplicate moves should have been removed.
|
||||
// test that the order hasn't changed
|
||||
assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
|
||||
@@ -1259,27 +1259,12 @@ suite('Events', function () {
|
||||
assert.equal(filteredEvents[1].newCoordinate.y, 3);
|
||||
});
|
||||
|
||||
test('Backward', function () {
|
||||
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);
|
||||
const filteredEvents = eventUtils.filter(events, false);
|
||||
assert.equal(filteredEvents.length, 2); // duplicate event should have been removed.
|
||||
// test that the order hasn't changed
|
||||
assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BlockCreate);
|
||||
assert.isTrue(filteredEvents[1] instanceof Blockly.Events.BlockMove);
|
||||
assert.equal(filteredEvents[1].newCoordinate.x, 1);
|
||||
assert.equal(filteredEvents[1].newCoordinate.y, 1);
|
||||
});
|
||||
|
||||
test('Merge block move events', function () {
|
||||
const block = this.workspace.newBlock('field_variable_test_block', '1');
|
||||
const events = [];
|
||||
addMoveEvent(events, block, 0, 0);
|
||||
addMoveEvent(events, block, 1, 1);
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
assert.equal(filteredEvents.length, 1); // second move event merged into first
|
||||
assert.equal(filteredEvents[0].newCoordinate.x, 1);
|
||||
assert.equal(filteredEvents[0].newCoordinate.y, 1);
|
||||
@@ -1297,7 +1282,7 @@ suite('Events', function () {
|
||||
'item2',
|
||||
),
|
||||
];
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
assert.equal(filteredEvents.length, 1); // second change event merged into first
|
||||
assert.equal(filteredEvents[0].oldValue, 'item');
|
||||
assert.equal(filteredEvents[0].newValue, 'item2');
|
||||
@@ -1308,7 +1293,7 @@ suite('Events', function () {
|
||||
new Blockly.Events.ViewportChange(1, 2, 3, this.workspace, 4),
|
||||
new Blockly.Events.ViewportChange(5, 6, 7, this.workspace, 8),
|
||||
];
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
assert.equal(filteredEvents.length, 1); // second change event merged into first
|
||||
assert.equal(filteredEvents[0].viewTop, 5);
|
||||
assert.equal(filteredEvents[0].viewLeft, 6);
|
||||
@@ -1328,7 +1313,7 @@ suite('Events', function () {
|
||||
new Blockly.Events.BubbleOpen(block3, true, 'warning'),
|
||||
new Blockly.Events.Click(block3),
|
||||
];
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
// click event merged into corresponding *Open event
|
||||
assert.equal(filteredEvents.length, 3);
|
||||
assert.isTrue(filteredEvents[0] instanceof Blockly.Events.BubbleOpen);
|
||||
@@ -1347,7 +1332,7 @@ suite('Events', function () {
|
||||
new Blockly.Events.Click(block),
|
||||
new Blockly.Events.BlockDrag(block, true),
|
||||
];
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
// click and stackclick should both exist
|
||||
assert.equal(filteredEvents.length, 2);
|
||||
assert.isTrue(filteredEvents[0] instanceof Blockly.Events.Click);
|
||||
@@ -1367,7 +1352,7 @@ suite('Events', function () {
|
||||
const events = [];
|
||||
addMoveEventParent(events, block, null);
|
||||
addMoveEventParent(events, block, null);
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
// The two events should be merged, but because nothing has changed
|
||||
// they will be filtered out.
|
||||
assert.equal(filteredEvents.length, 0);
|
||||
@@ -1388,7 +1373,7 @@ suite('Events', function () {
|
||||
events.push(new Blockly.Events.BlockDelete(block2));
|
||||
addMoveEvent(events, block1, 2, 2);
|
||||
|
||||
const filteredEvents = eventUtils.filter(events, true);
|
||||
const filteredEvents = eventUtils.filter(events);
|
||||
// Nothing should have merged.
|
||||
assert.equal(filteredEvents.length, 4);
|
||||
// test that the order hasn't changed
|
||||
|
||||
Reference in New Issue
Block a user