Files
blockly/tests/mocha/render_management_test.js
Beka Westberg 7d2c307fed fix: widget positioning (#7507)
* 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
2023-10-26 09:47:39 -07:00

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;
});
});
});