mirror of
https://github.com/google/blockly.git
synced 2025-12-15 22:00:07 +01:00
* chore: delete dead code * chore: moves location updating into the block * chore: change dragging to use update component locations * fix: field widgets not being moved when blocks are editted * chore: remove unnecessary resizeEditor_ calls * chore: format * chore: fix build * fix: tests * chore: PR comments * chore: format
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {
|
|
sharedTestSetup,
|
|
sharedTestTeardown,
|
|
} from './test_helpers/setup_teardown.js';
|
|
|
|
suite('Render Management', function () {
|
|
setup(function () {
|
|
this.clock = sharedTestSetup.call(this).clock;
|
|
});
|
|
|
|
teardown(function () {
|
|
sharedTestTeardown.call(this);
|
|
});
|
|
|
|
suite('finish queued renders callback', function () {
|
|
function createMockBlock() {
|
|
return {
|
|
hasRendered: false,
|
|
renderEfficiently: function () {
|
|
this.hasRendered = true;
|
|
},
|
|
|
|
// All of the APIs the render management system needs.
|
|
getParent: () => null,
|
|
getChildren: () => [],
|
|
isDisposed: () => false,
|
|
getRelativeToSurfaceXY: () => ({x: 0, y: 0}),
|
|
updateComponentLocations: () => {},
|
|
workspace: {
|
|
resizeContents: () => {},
|
|
},
|
|
};
|
|
}
|
|
|
|
test('the queueRender promise is properly resolved after rendering', function () {
|
|
const block = createMockBlock();
|
|
const promise = Blockly.renderManagement.queueRender(block).then(() => {
|
|
chai.assert.isTrue(block.hasRendered, 'Expected block to be rendered');
|
|
});
|
|
this.clock.runAll();
|
|
return promise;
|
|
});
|
|
|
|
test('the finish queued renders promise is properly resolved after rendering', function () {
|
|
const block = createMockBlock();
|
|
Blockly.renderManagement.queueRender(block);
|
|
const promise = Blockly.renderManagement.finishQueuedRenders(() => {
|
|
chai.assert.isTrue(block.hasRendered, 'Expected block to be rendered');
|
|
});
|
|
this.clock.runAll();
|
|
return promise;
|
|
});
|
|
});
|
|
});
|