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:
Beka Westberg
2023-08-11 09:38:50 -07:00
committed by GitHub
parent a901c62d0c
commit e30c4acd92
6 changed files with 38 additions and 27 deletions

View File

@@ -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 () {

View File

@@ -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',