- Bundle robot3 1.3.0 locally (not yet published to npm) - Fix remaining type inference issues with `as any` casts for invoke() events Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
28 lines
830 B
JavaScript
28 lines
830 B
JavaScript
import { createMachine, interpret, state, transition, reduce, d} from '../machine.js';
|
|
|
|
QUnit.module('robot/logging');
|
|
|
|
QUnit.test('Calls the onEnter function if the state is changed', assert => {
|
|
const machine = createMachine({
|
|
one: state(
|
|
transition('go', 'two', reduce((ctx) => (
|
|
{ ...ctx, x: 1 }
|
|
)))
|
|
),
|
|
two: state()
|
|
}, () => ({x: 0, y: 0}));
|
|
|
|
const service = interpret(machine, () => {});
|
|
const enterFN = (m, to, state, prevState, event) => {
|
|
assert.deepEqual(m, machine, 'Machines equal');
|
|
assert.deepEqual(state, {x:1, y:0}, 'Changed state passed.')
|
|
assert.deepEqual(prevState, {x:0, y:0}, 'Previous state passed.')
|
|
assert.equal(to, 'two', 'To state passed.')
|
|
assert.equal(event, 'go', 'Send event passed.')
|
|
}
|
|
|
|
d._onEnter = enterFN;
|
|
|
|
service.send('go');
|
|
});
|