deno.land / x / xstate@xstate@4.33.6 / test / resolve.test.ts

resolve.test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { 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: {} } } } }); });});
xstate

Version Info

Tagged at
2 years ago