Only send monitor update on change

This commit is contained in:
DD Liu 2017-05-19 12:28:05 -04:00
parent e9c48d250b
commit 9645a513b1
2 changed files with 85 additions and 9 deletions

View file

@ -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();
});