mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
* chore: add and configure prettier * chore: remove clang-format * chore: remove clang-format config * chore: lint additional ts files * chore: fix lint errors in blocks * chore: add prettier-ignore where needed * chore: ignore js blocks when formatting * chore: fix playground html syntax * chore: fix yaml spacing from merge * chore: convert text blocks to use arrow functions * chore: format everything with prettier * chore: fix lint unused imports in blocks
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.declareModuleId('Blockly.test.renderManagement');
|
|
|
|
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,
|
|
getConnections_: () => [],
|
|
getRelativeToSurfaceXY: () => ({x: 0, y: 0}),
|
|
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;
|
|
});
|
|
});
|
|
});
|