mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-25 21:50:59 -04:00
Only send monitor update on change
This commit is contained in:
parent
e9c48d250b
commit
9645a513b1
2 changed files with 85 additions and 9 deletions
test/unit
|
@ -10,3 +10,49 @@ test('spec', t => {
|
|||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('monitorWouldChange_false', t => {
|
||||
const r = new Runtime();
|
||||
const currentMonitorState = {
|
||||
id: 'xklj4#!',
|
||||
category: 'data',
|
||||
label: 'turtle whereabouts',
|
||||
value: '25',
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
const newMonitorDelta = {
|
||||
id: 'xklj4#!',
|
||||
value: String(25)
|
||||
};
|
||||
t.equals(false, r._monitorWouldChange(currentMonitorState, newMonitorDelta));
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('monitorWouldChange_true', t => {
|
||||
const r = new Runtime();
|
||||
const currentMonitorState = {
|
||||
id: 'xklj4#!',
|
||||
category: 'data',
|
||||
label: 'turtle whereabouts',
|
||||
value: '25',
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
|
||||
// Value change
|
||||
let newMonitorDelta = {
|
||||
id: 'xklj4#!',
|
||||
value: String(24)
|
||||
};
|
||||
t.equal(true, r._monitorWouldChange(currentMonitorState, newMonitorDelta));
|
||||
|
||||
// Prop change
|
||||
newMonitorDelta = {
|
||||
id: 'xklj4#!',
|
||||
moose: 7
|
||||
};
|
||||
t.equal(true, r._monitorWouldChange(currentMonitorState, newMonitorDelta));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue