mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
chore: upgrade keyboard shortcuts and context menus to use non-deprecated APIs (#7352)
* chore: remove references to clipboard.copy in shortcuts * chore: remove references to clipboard.copy in context menus * chore: fix tests * chore: format * fix: PR comments
This commit is contained in:
@@ -419,13 +419,13 @@ suite('Context Menu Items', function () {
|
||||
);
|
||||
});
|
||||
|
||||
test('Calls duplicate', function () {
|
||||
const spy = sinon.spy(Blockly.clipboard.TEST_ONLY, 'duplicateInternal');
|
||||
|
||||
test('the block is duplicated', function () {
|
||||
this.duplicateOption.callback(this.scope);
|
||||
|
||||
sinon.assert.calledOnce(spy);
|
||||
sinon.assert.calledWith(spy, this.block);
|
||||
chai.assert.equal(
|
||||
this.workspace.getTopBlocks(false).length,
|
||||
2,
|
||||
'Expected a second block',
|
||||
);
|
||||
});
|
||||
|
||||
test('Has correct label', function () {
|
||||
|
||||
@@ -26,10 +26,13 @@ suite('Key Down', function () {
|
||||
/**
|
||||
* Creates a block and sets it as Blockly.selected.
|
||||
* @param {Blockly.Workspace} workspace The workspace to create a new block on.
|
||||
* @return {Blockly.Block} The block being selected.
|
||||
*/
|
||||
function setSelectedBlock(workspace) {
|
||||
defineStackBlock();
|
||||
Blockly.common.setSelected(workspace.newBlock('stack_block'));
|
||||
const block = workspace.newBlock('stack_block');
|
||||
Blockly.common.setSelected(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,8 +112,8 @@ suite('Key Down', function () {
|
||||
|
||||
suite('Copy', function () {
|
||||
setup(function () {
|
||||
setSelectedBlock(this.workspace);
|
||||
this.copySpy = sinon.spy(Blockly.clipboard.TEST_ONLY, 'copyInternal');
|
||||
this.block = setSelectedBlock(this.workspace);
|
||||
this.copySpy = sinon.spy(this.block, 'toCopyData');
|
||||
this.hideChaffSpy = sinon.spy(
|
||||
Blockly.WorkspaceSvg.prototype,
|
||||
'hideChaff',
|
||||
|
||||
Reference in New Issue
Block a user