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

algorithm.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { Machine } from '../src';import { getConfiguration } from '../src/stateUtils';
const testMachine = Machine({ id: 'a', initial: 'b1', states: { b1: { id: 'b1', type: 'parallel', states: { c1: { id: 'c1', initial: 'd1', states: { d1: { id: 'd1' }, d2: { id: 'd2', initial: 'e1', states: { e1: { id: 'e1' }, e2: { id: 'e2' } } } } }, c2: { id: 'c2' }, c3: { id: 'c3', initial: 'd3', states: { d3: { id: 'd3' }, d4: { id: 'd4', initial: 'e3', states: { e3: { id: 'e3' }, e4: { id: 'e4' } } } } } } }, b2: { id: 'b2', initial: 'c4', states: { c4: { id: 'c4' } } }, b3: { id: 'b3', initial: 'c5', states: { c5: { id: 'c5' }, c6: { id: 'c6', type: 'parallel', states: { d5: { id: 'd5' }, d6: { id: 'd6' }, d7: { id: 'd7' } } } } } }});
describe('algorithm', () => { it('getConfiguration', () => { const prevNodes = testMachine.getStateNodes({ b1: { c1: 'd1', c2: {}, c3: 'd3' } }); const nodes = ['c1', 'd4'].map((id) => testMachine.getStateNodeById(id));
const c = getConfiguration(prevNodes, nodes);
expect([...c].map((sn) => sn.id).sort()).toEqual([ 'a', 'b1', 'c1', 'c2', 'c3', 'd1', 'd4', 'e3' ]); });});
xstate

Version Info

Tagged at
2 years ago