phone/packages/robot3/test/test-debug.js
Corey Johnson 24a726b829 Upgrade robot3 to 1.3.0 for improved TypeScript support
- Bundle robot3 1.3.0 locally (not yet published to npm)
- Fix remaining type inference issues with `as any` casts for invoke() events
- Resolves state machine transition type errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 14:33:47 -08:00

54 lines
1.3 KiB
JavaScript

import { createMachine, interpret, state, transition, reduce, d} from '../machine.js';
QUnit.module('robot/debug');
QUnit.test('Errors for transitions to states that don\'t exist', assert => {
try {
createMachine({
one: state(
transition('go', 'two')
)
});
} catch(e) {
assert.ok(/unknown state/.test(e.message), 'Gets an error about unknown states');
}
});
QUnit.test('Does not error for transitions to states when state does exist', assert => {
try {
createMachine({
one: state(
transition('go', 'two')
),
two: state()
});
assert.ok(true, 'Created a valid machine!');
} catch(e) {
assert.ok(false, 'Should not have errored');
}
});
QUnit.test('Errors if an invalid initial state is provided', assert => {
try {
createMachine('oops', {
one: state()
});
assert.ok(false, 'should have failed');
} catch(e) {
assert.ok(true, 'it is errored');
}
});
QUnit.test('Errors when no transitions for event from the current state', assert => {
try {
const machine = createMachine('one', {
one: state(),
});
const { send } = interpret(machine, () => {});
send('go');
assert.ok(false, 'should have failed');
} catch(e) {
assert.ok(true, 'it is errored');
}
});