deno.land / x / xstate@xstate@4.33.6 / test / resolve.test.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import { Machine } from '../src/index';
// from parallel/test3.scxmlconst flatParallelMachine = Machine({ id: 'fp', initial: 'p1', states: { p1: { type: 'parallel', states: { s1: { initial: 'p2', states: { p2: { type: 'parallel', states: { s3: { initial: 's3.1', states: { 's3.1': {}, 's3.2': {} } }, s4: {} } }, p3: { type: 'parallel', states: { s5: {}, s6: {} } } } }, s2: { initial: 'p4', states: { p4: { type: 'parallel', states: { s7: {}, s8: {} } }, p5: { type: 'parallel', states: { s9: {}, s10: {} } } } } } } }});
describe('machine.resolve()', () => { it('should resolve parallel states with flat child states', () => { const unresolvedStateValue = { p1: { s1: { p2: 's4' }, s2: { p4: 's8' } } };
const resolvedStateValue = flatParallelMachine.resolve( unresolvedStateValue ); expect(resolvedStateValue).toEqual({ p1: { s1: { p2: { s3: 's3.1', s4: {} } }, s2: { p4: { s7: {}, s8: {} } } } }); });});
Version Info