Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Aug 2, 2023
1 parent 12d1793 commit a9ef840
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions tests/mocha/contextmenu_items_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
9 changes: 6 additions & 3 deletions tests/mocha/keydown_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit a9ef840

Please sign in to comment.