feat: added intermediate event change (#7671)

* feat: added intermediate event change

* fix: update prettier format for the code

* fix: update comment style

* fix: update test statements
This commit is contained in:
truongductri01
2023-12-04 16:10:09 -05:00
committed by GitHub
parent 0a27e1c472
commit 96a354b46b
2 changed files with 64 additions and 0 deletions

View File

@@ -35,4 +35,38 @@ suite('Field Intermediate Change Event', function () {
chai.assert.deepEqual(newEvent, origEvent);
});
});
suite('Change Value', function () {
test("running forward changes the block's value to new value", function () {
const block = this.workspace.newBlock('text', 'block_id');
const origEvent = new Blockly.Events.BlockFieldIntermediateChange(
block,
'TEXT',
'old value',
'new value',
);
origEvent.run(true);
chai.assert.deepEqual(
block.getField(origEvent.name).getValue(),
'new value',
);
});
test("running backward changes the block's value to old value", function () {
const block = this.workspace.newBlock('text', 'block_id');
const origEvent = new Blockly.Events.BlockFieldIntermediateChange(
block,
'TEXT',
'old value',
'new value',
);
origEvent.run(false);
chai.assert.deepEqual(
block.getField(origEvent.name).getValue(),
'old value',
);
});
});
});