Skip to content

Commit 8cf371a

Browse files
authored
chore: Fix minimap mirror test (#10256)
* chore: remove test timeouts and add fake timers * chore: removed async
1 parent 7c14e2a commit 8cf371a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/plugins/workspace-minimap/test/minimap_tests.mocha.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ suite('Mirroring events', function () {
444444
window.HTMLCanvasElement.prototype.getContext = () => ({
445445
measureText: () => ({width: ''}),
446446
});
447+
this.clock = sinon.useFakeTimers();
447448
window.requestAnimationFrame = (callback) => setTimeout(callback, 0);
448449
window.cancelAnimationFrame = (id) => clearTimeout(id);
449450
this.workspace = Blockly.inject('blocklyDiv', {
@@ -456,17 +457,18 @@ suite('Mirroring events', function () {
456457
teardown(function () {
457458
this.minimap.dispose();
458459
this.workspace.dispose();
460+
this.clock.runAll();
461+
sinon.restore();
459462
this.jsdomCleanup();
460463
});
461464

462-
test('Renaming a variable updates the minimap', async function () {
465+
test('Renaming a variable updates the minimap', function () {
463466
const variable = this.workspace.getVariableMap().createVariable('a');
464467
const block = this.workspace.newBlock('variables_set');
465468
block.getField('VAR').setValue(variable.getId());
466-
await new Promise((resolve) => setTimeout(resolve, 0));
467469

468470
this.workspace.getVariableMap().renameVariable(variable, 'b');
469-
await new Promise((resolve) => setTimeout(resolve, 0));
471+
this.clock.tick(1);
470472

471473
const minimapBlock = this.minimap.minimapWorkspace.getBlockById(block.id);
472474
assert.equal(

0 commit comments

Comments
 (0)