scratch-vm/test/unit/engine_runtime.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

const test = require('tap').test;
const Runtime = require('../../src/engine/runtime');
2016-04-18 17:20:30 -04:00
test('spec', t => {
const r = new Runtime();
2016-04-18 17:20:30 -04:00
t.type(Runtime, 'function');
t.type(r, 'object');
t.ok(r instanceof Runtime);
t.end();
});
2017-05-19 12:28:05 -04:00
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();
});