@rango-dev/wallets-core 0.37.1-next.1 → 0.38.1-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/builders/action.d.ts +22 -0
  3. package/dist/builders/action.d.ts.map +1 -0
  4. package/dist/builders/mod.d.ts +5 -0
  5. package/dist/builders/mod.d.ts.map +1 -0
  6. package/dist/builders/namespace.d.ts +47 -0
  7. package/dist/builders/namespace.d.ts.map +1 -0
  8. package/dist/builders/provider.d.ts +13 -0
  9. package/dist/builders/provider.d.ts.map +1 -0
  10. package/dist/builders/types.d.ts +21 -0
  11. package/dist/builders/types.d.ts.map +1 -0
  12. package/dist/hub/helpers.d.ts +6 -0
  13. package/dist/hub/helpers.d.ts.map +1 -0
  14. package/dist/hub/hub.d.ts +28 -0
  15. package/dist/hub/hub.d.ts.map +1 -0
  16. package/dist/hub/mod.d.ts +7 -0
  17. package/dist/hub/mod.d.ts.map +1 -0
  18. package/dist/hub/namespaces/errors.d.ts +4 -0
  19. package/dist/hub/namespaces/errors.d.ts.map +1 -0
  20. package/dist/hub/namespaces/mod.d.ts +3 -0
  21. package/dist/hub/namespaces/mod.d.ts.map +1 -0
  22. package/dist/hub/namespaces/namespace.d.ts +146 -0
  23. package/dist/hub/namespaces/namespace.d.ts.map +1 -0
  24. package/dist/hub/namespaces/namespace.test.d.ts +2 -0
  25. package/dist/hub/namespaces/namespace.test.d.ts.map +1 -0
  26. package/dist/hub/namespaces/types.d.ts +33 -0
  27. package/dist/hub/namespaces/types.d.ts.map +1 -0
  28. package/dist/hub/provider/mod.d.ts +3 -0
  29. package/dist/hub/provider/mod.d.ts.map +1 -0
  30. package/dist/hub/provider/provider.d.ts +136 -0
  31. package/dist/hub/provider/provider.d.ts.map +1 -0
  32. package/dist/hub/provider/provider.test.d.ts +2 -0
  33. package/dist/hub/provider/provider.test.d.ts.map +1 -0
  34. package/dist/hub/provider/types.d.ts +28 -0
  35. package/dist/hub/provider/types.d.ts.map +1 -0
  36. package/dist/hub/store/hub.d.ts +11 -0
  37. package/dist/hub/store/hub.d.ts.map +1 -0
  38. package/dist/hub/store/mod.d.ts +6 -0
  39. package/dist/hub/store/mod.d.ts.map +1 -0
  40. package/dist/hub/store/namespaces.d.ts +34 -0
  41. package/dist/hub/store/namespaces.d.ts.map +1 -0
  42. package/dist/hub/store/providers.d.ts +45 -0
  43. package/dist/hub/store/providers.d.ts.map +1 -0
  44. package/dist/hub/store/selectors.d.ts +18 -0
  45. package/dist/hub/store/selectors.d.ts.map +1 -0
  46. package/dist/hub/store/store.d.ts +13 -0
  47. package/dist/hub/store/store.d.ts.map +1 -0
  48. package/dist/hub/store/store.test.d.ts +2 -0
  49. package/dist/hub/store/store.test.d.ts.map +1 -0
  50. package/dist/mod.d.ts +6 -1
  51. package/dist/mod.d.ts.map +1 -1
  52. package/dist/mod.js +1 -0
  53. package/dist/mod.js.map +4 -4
  54. package/dist/namespaces/common/actions.d.ts +4 -0
  55. package/dist/namespaces/common/actions.d.ts.map +1 -0
  56. package/dist/namespaces/common/after.d.ts +4 -0
  57. package/dist/namespaces/common/after.d.ts.map +1 -0
  58. package/dist/namespaces/common/and.d.ts +6 -0
  59. package/dist/namespaces/common/and.d.ts.map +1 -0
  60. package/dist/namespaces/common/before.d.ts +4 -0
  61. package/dist/namespaces/common/before.d.ts.map +1 -0
  62. package/dist/namespaces/common/builders.d.ts +4 -0
  63. package/dist/namespaces/common/builders.d.ts.map +1 -0
  64. package/dist/namespaces/common/helpers.d.ts +2 -0
  65. package/dist/namespaces/common/helpers.d.ts.map +1 -0
  66. package/dist/namespaces/common/mod.d.ts +6 -0
  67. package/dist/namespaces/common/mod.d.ts.map +1 -0
  68. package/dist/namespaces/common/mod.js +2 -0
  69. package/dist/namespaces/common/mod.js.map +7 -0
  70. package/dist/namespaces/common/types.d.ts +7 -0
  71. package/dist/namespaces/common/types.d.ts.map +1 -0
  72. package/dist/namespaces/cosmos/mod.d.ts +2 -0
  73. package/dist/namespaces/cosmos/mod.d.ts.map +1 -0
  74. package/dist/namespaces/cosmos/types.d.ts +4 -0
  75. package/dist/namespaces/cosmos/types.d.ts.map +1 -0
  76. package/dist/namespaces/evm/actions.d.ts +8 -0
  77. package/dist/namespaces/evm/actions.d.ts.map +1 -0
  78. package/dist/namespaces/evm/after.d.ts +2 -0
  79. package/dist/namespaces/evm/after.d.ts.map +1 -0
  80. package/dist/namespaces/evm/and.d.ts +3 -0
  81. package/dist/namespaces/evm/and.d.ts.map +1 -0
  82. package/dist/namespaces/evm/before.d.ts +2 -0
  83. package/dist/namespaces/evm/before.d.ts.map +1 -0
  84. package/dist/namespaces/evm/builders.d.ts +4 -0
  85. package/dist/namespaces/evm/builders.d.ts.map +1 -0
  86. package/dist/namespaces/evm/constants.d.ts +3 -0
  87. package/dist/namespaces/evm/constants.d.ts.map +1 -0
  88. package/dist/namespaces/evm/eip1193.d.ts +1228 -0
  89. package/dist/namespaces/evm/eip1193.d.ts.map +1 -0
  90. package/dist/namespaces/evm/mod.d.ts +9 -0
  91. package/dist/namespaces/evm/mod.d.ts.map +1 -0
  92. package/dist/namespaces/evm/mod.js +2 -0
  93. package/dist/namespaces/evm/mod.js.map +7 -0
  94. package/dist/namespaces/evm/types.d.ts +10 -0
  95. package/dist/namespaces/evm/types.d.ts.map +1 -0
  96. package/dist/namespaces/evm/utils.d.ts +9 -0
  97. package/dist/namespaces/evm/utils.d.ts.map +1 -0
  98. package/dist/namespaces/solana/actions.d.ts +6 -0
  99. package/dist/namespaces/solana/actions.d.ts.map +1 -0
  100. package/dist/namespaces/solana/after.d.ts +2 -0
  101. package/dist/namespaces/solana/after.d.ts.map +1 -0
  102. package/dist/namespaces/solana/and.d.ts +3 -0
  103. package/dist/namespaces/solana/and.d.ts.map +1 -0
  104. package/dist/namespaces/solana/before.d.ts +2 -0
  105. package/dist/namespaces/solana/before.d.ts.map +1 -0
  106. package/dist/namespaces/solana/builders.d.ts +4 -0
  107. package/dist/namespaces/solana/builders.d.ts.map +1 -0
  108. package/dist/namespaces/solana/constants.d.ts +3 -0
  109. package/dist/namespaces/solana/constants.d.ts.map +1 -0
  110. package/dist/namespaces/solana/mod.d.ts +8 -0
  111. package/dist/namespaces/solana/mod.d.ts.map +1 -0
  112. package/dist/namespaces/solana/mod.js +2 -0
  113. package/dist/namespaces/solana/mod.js.map +7 -0
  114. package/dist/namespaces/solana/types.d.ts +7 -0
  115. package/dist/namespaces/solana/types.d.ts.map +1 -0
  116. package/dist/test-utils/fixtures.d.ts +3 -0
  117. package/dist/test-utils/fixtures.d.ts.map +1 -0
  118. package/dist/types/accounts.d.ts +11 -0
  119. package/dist/types/accounts.d.ts.map +1 -0
  120. package/dist/types/actions.d.ts +5 -0
  121. package/dist/types/actions.d.ts.map +1 -0
  122. package/dist/types/utils.d.ts +7 -0
  123. package/dist/types/utils.d.ts.map +1 -0
  124. package/dist/utils/mod.d.ts +4 -0
  125. package/dist/utils/mod.d.ts.map +1 -0
  126. package/dist/utils/mod.js +2 -0
  127. package/dist/utils/mod.js.map +7 -0
  128. package/dist/utils/versions.d.ts +21 -0
  129. package/dist/utils/versions.d.ts.map +1 -0
  130. package/dist/utils/versions.test.d.ts +2 -0
  131. package/dist/utils/versions.test.d.ts.map +1 -0
  132. package/dist/wallets-core.build.json +1 -1
  133. package/package.json +25 -4
  134. package/src/builders/action.ts +86 -0
  135. package/src/builders/mod.ts +5 -0
  136. package/src/builders/namespace.ts +229 -0
  137. package/src/builders/provider.ts +61 -0
  138. package/src/builders/types.ts +29 -0
  139. package/src/hub/helpers.ts +11 -0
  140. package/src/hub/hub.ts +122 -0
  141. package/src/hub/mod.ts +10 -0
  142. package/src/hub/namespaces/errors.ts +8 -0
  143. package/src/hub/namespaces/mod.ts +9 -0
  144. package/src/hub/namespaces/namespace.test.ts +333 -0
  145. package/src/hub/namespaces/namespace.ts +443 -0
  146. package/src/hub/namespaces/types.ts +50 -0
  147. package/src/hub/provider/mod.ts +9 -0
  148. package/src/hub/provider/provider.test.ts +231 -0
  149. package/src/hub/provider/provider.ts +330 -0
  150. package/src/hub/provider/types.ts +37 -0
  151. package/src/hub/store/hub.ts +18 -0
  152. package/src/hub/store/mod.ts +8 -0
  153. package/src/hub/store/namespaces.ts +90 -0
  154. package/src/hub/store/providers.ts +97 -0
  155. package/src/hub/store/selectors.ts +59 -0
  156. package/src/hub/store/store.test.ts +32 -0
  157. package/src/hub/store/store.ts +26 -0
  158. package/src/mod.ts +35 -1
  159. package/src/namespaces/common/actions.ts +11 -0
  160. package/src/namespaces/common/after.ts +8 -0
  161. package/src/namespaces/common/and.ts +42 -0
  162. package/src/namespaces/common/before.ts +9 -0
  163. package/src/namespaces/common/builders.ts +19 -0
  164. package/src/namespaces/common/helpers.ts +10 -0
  165. package/src/namespaces/common/mod.ts +12 -0
  166. package/src/namespaces/common/types.ts +7 -0
  167. package/src/namespaces/cosmos/mod.ts +1 -0
  168. package/src/namespaces/cosmos/types.ts +10 -0
  169. package/src/namespaces/evm/actions.ts +97 -0
  170. package/src/namespaces/evm/after.ts +3 -0
  171. package/src/namespaces/evm/and.ts +5 -0
  172. package/src/namespaces/evm/before.ts +3 -0
  173. package/src/namespaces/evm/builders.ts +10 -0
  174. package/src/namespaces/evm/constants.ts +2 -0
  175. package/src/namespaces/evm/eip1193.ts +1414 -0
  176. package/src/namespaces/evm/mod.ts +9 -0
  177. package/src/namespaces/evm/types.ts +18 -0
  178. package/src/namespaces/evm/utils.ts +52 -0
  179. package/src/namespaces/solana/actions.ts +70 -0
  180. package/src/namespaces/solana/after.ts +3 -0
  181. package/src/namespaces/solana/and.ts +5 -0
  182. package/src/namespaces/solana/before.ts +3 -0
  183. package/src/namespaces/solana/builders.ts +10 -0
  184. package/src/namespaces/solana/constants.ts +2 -0
  185. package/src/namespaces/solana/mod.ts +8 -0
  186. package/src/namespaces/solana/types.ts +20 -0
  187. package/src/test-utils/fixtures.ts +9 -0
  188. package/src/types/accounts.ts +12 -0
  189. package/src/types/actions.ts +11 -0
  190. package/src/types/utils.ts +7 -0
  191. package/src/utils/mod.ts +8 -0
  192. package/src/utils/versions.test.ts +22 -0
  193. package/src/utils/versions.ts +63 -0
@@ -0,0 +1,333 @@
1
+ import { describe, expect, test, vi } from 'vitest';
2
+
3
+ import { createStore } from '../mod.js';
4
+
5
+ import { OR_ELSE_ACTION_FAILED_ERROR } from './errors.js';
6
+ import { Namespace } from './namespace.js';
7
+
8
+ interface TestNamespaceActions {
9
+ connect: () => void;
10
+ disconnect: () => void;
11
+ }
12
+
13
+ describe('check initializing Namespace', () => {
14
+ const NAMESPACE = 'evm';
15
+ const PROVIDER_ID = 'garbage provider';
16
+
17
+ test('initialize a namespace and run an action', () => {
18
+ const connect = vi.fn();
19
+ const disconnect = vi.fn();
20
+ const actions = new Map();
21
+ actions.set('connect', connect);
22
+ actions.set('disconnect', disconnect);
23
+
24
+ const ns = new Namespace<TestNamespaceActions>(NAMESPACE, PROVIDER_ID, {
25
+ actions: actions,
26
+ });
27
+
28
+ ns.run('connect');
29
+
30
+ expect(disconnect).toBeCalledTimes(0);
31
+ expect(connect).toBeCalledTimes(1);
32
+ });
33
+
34
+ test('init action should be called once', () => {
35
+ const connect = vi.fn();
36
+ const disconnect = vi.fn();
37
+ const init = vi.fn();
38
+ const actions = new Map();
39
+ actions.set('connect', connect);
40
+ actions.set('disconnect', disconnect);
41
+ actions.set('init', init);
42
+
43
+ const ns = new Namespace<TestNamespaceActions>(NAMESPACE, PROVIDER_ID, {
44
+ actions: actions,
45
+ });
46
+
47
+ expect(init).toBeCalledTimes(0);
48
+
49
+ ns.run('connect');
50
+ ns.init();
51
+ ns.init();
52
+
53
+ expect(disconnect).toBeCalledTimes(0);
54
+ expect(connect).toBeCalledTimes(1);
55
+ expect(init).toBeCalledTimes(1);
56
+ });
57
+
58
+ test('state should be updated and actions have access to them', () => {
59
+ const connect = vi.fn((context) => {
60
+ const [, setState] = context.state();
61
+ setState('connected', true);
62
+ });
63
+ const init = vi.fn((context) => {
64
+ const [, setState] = context.state();
65
+ setState('connecting', true);
66
+ });
67
+ const actions = new Map();
68
+ actions.set('connect', connect);
69
+ actions.set('init', init);
70
+
71
+ const store = createStore();
72
+ const ns = new Namespace<TestNamespaceActions>(NAMESPACE, PROVIDER_ID, {
73
+ actions: actions,
74
+ store,
75
+ });
76
+
77
+ ns.run('connect');
78
+ ns.init();
79
+ ns.init();
80
+
81
+ const [currentState] = ns.state();
82
+ expect(currentState().connected).toBe(true);
83
+ expect(currentState('connecting')).toBe(true);
84
+ });
85
+
86
+ test("throw an error if store doesn't set", () => {
87
+ const ns = new Namespace<TestNamespaceActions>(NAMESPACE, PROVIDER_ID, {
88
+ actions: new Map(),
89
+ });
90
+
91
+ expect(() => ns.state()).toThrowError();
92
+ });
93
+ });
94
+
95
+ describe('check actions with hooks and operators', () => {
96
+ const NAMESPACE = 'bip122';
97
+ const PROVIDER_ID = 'garbage provider';
98
+
99
+ test('add actions and run them.', () => {
100
+ const actions = new Map();
101
+ actions.set('hello', () => 'hello world');
102
+ actions.set('bye', () => 'bye bye');
103
+ actions.set('chainable', () => "it's also chainable");
104
+ actions.set('chain2', () => "it's also chainable");
105
+
106
+ const ns = new Namespace<{
107
+ hello: () => string;
108
+ bye: () => string;
109
+ chainable: () => void;
110
+ chain2: () => void;
111
+ }>(NAMESPACE, PROVIDER_ID, { actions });
112
+
113
+ expect(ns.run('hello')).toBe('hello world');
114
+ expect(ns.run('bye')).toBe('bye bye');
115
+
116
+ expect(() => {
117
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
118
+ // @ts-ignore-next-line
119
+ return ns.run('some_action_name_that_has_not_added');
120
+ }).toThrowError();
121
+ });
122
+
123
+ test('should be called before/after target action correctly even with multiple hook assigned to an action name', () => {
124
+ const beforeAction = vi.fn();
125
+ const anotherBeforeAction = vi.fn();
126
+ const afterAction = vi.fn();
127
+ const anotherAfterAction = vi.fn();
128
+ const connectAction = vi.fn();
129
+ const disconnectAction = vi.fn();
130
+
131
+ const actions = new Map();
132
+ actions.set('connect', connectAction);
133
+ actions.set('disconnect', disconnectAction);
134
+
135
+ const ns = new Namespace<TestNamespaceActions>(NAMESPACE, PROVIDER_ID, {
136
+ actions,
137
+ });
138
+
139
+ ns.run('connect');
140
+ expect(connectAction).toBeCalledTimes(1);
141
+ expect(beforeAction).toBeCalledTimes(0);
142
+ expect(anotherBeforeAction).toBeCalledTimes(0);
143
+ expect(afterAction).toBeCalledTimes(0);
144
+ expect(anotherAfterAction).toBeCalledTimes(0);
145
+
146
+ ns.before('connect', beforeAction);
147
+ ns.before('connect', anotherBeforeAction);
148
+ ns.run('connect');
149
+ expect(connectAction).toBeCalledTimes(2);
150
+ expect(beforeAction).toBeCalledTimes(1);
151
+ expect(anotherBeforeAction).toBeCalledTimes(1);
152
+ expect(afterAction).toBeCalledTimes(0);
153
+ expect(anotherAfterAction).toBeCalledTimes(0);
154
+
155
+ ns.after('connect', afterAction);
156
+ ns.after('connect', anotherAfterAction);
157
+ ns.run('connect');
158
+ expect(beforeAction).toBeCalledTimes(2);
159
+ expect(anotherBeforeAction).toBeCalledTimes(2);
160
+ expect(afterAction).toBeCalledTimes(1);
161
+ expect(anotherAfterAction).toBeCalledTimes(1);
162
+ });
163
+
164
+ test('should call `and_then` sequentially.', () => {
165
+ const andActionFirst = vi.fn((_ctx, result) => result + 1);
166
+ const andActionSecond = vi.fn((_ctx, result) => result + 1);
167
+
168
+ const connectAction = vi.fn(() => 0);
169
+ const disconnectAction = vi.fn();
170
+
171
+ const actions = new Map();
172
+ actions.set('connect', connectAction);
173
+ actions.set('disconnect', disconnectAction);
174
+
175
+ const ns = new Namespace<TestNamespaceActions>(NAMESPACE, PROVIDER_ID, {
176
+ actions: actions,
177
+ });
178
+ ns.and_then('connect', andActionFirst);
179
+ ns.and_then('connect', andActionSecond);
180
+
181
+ const result = ns.run('connect');
182
+
183
+ expect(connectAction).toBeCalledTimes(1);
184
+ expect(andActionFirst).toBeCalledTimes(1);
185
+ expect(andActionSecond).toBeCalledTimes(1);
186
+
187
+ expect(result).toBe(2);
188
+
189
+ ns.run('connect');
190
+ expect(connectAction).toBeCalledTimes(2);
191
+ expect(andActionFirst).toBeCalledTimes(2);
192
+ expect(andActionSecond).toBeCalledTimes(2);
193
+ });
194
+
195
+ test("shouldn't run other `and_then` hooks if one of them fails then fallback to `or_else`.", () => {
196
+ const andActionFirst = vi.fn((_ctx, _result) => {
197
+ throw new Error('Oops!');
198
+ });
199
+ const andActionSecond = vi.fn((_ctx, result) => result + 1);
200
+
201
+ const orAction = vi.fn((_ctx, e) => e instanceof Error);
202
+
203
+ const connectAction = vi.fn(() => 0);
204
+ const actions = new Map();
205
+ actions.set('connect', connectAction);
206
+
207
+ const ns = new Namespace<{
208
+ connect: () => void;
209
+ }>(NAMESPACE, PROVIDER_ID, {
210
+ actions: actions,
211
+ configs: {},
212
+ });
213
+ ns.and_then('connect', andActionFirst);
214
+ ns.and_then('connect', andActionSecond);
215
+
216
+ ns.or_else('connect', orAction);
217
+
218
+ const result = ns.run('connect');
219
+
220
+ expect(connectAction).toBeCalledTimes(1);
221
+ expect(andActionFirst).toBeCalledTimes(1);
222
+ expect(andActionSecond).toBeCalledTimes(0);
223
+ expect(orAction).toBeCalledTimes(1);
224
+ expect(result).toBe(true);
225
+ });
226
+
227
+ test('should throw error if there are no `or` to handle error', () => {
228
+ const andActionFirst = vi.fn((_ctx, _result) => {
229
+ throw new Error('Oops!');
230
+ });
231
+ const andActionSecond = vi.fn((_ctx, result) => result + 1);
232
+
233
+ const connectAction = vi.fn(() => 0);
234
+ const actions = new Map();
235
+ actions.set('connect', connectAction);
236
+
237
+ const ns = new Namespace<{
238
+ connect: () => void;
239
+ }>(NAMESPACE, PROVIDER_ID, {
240
+ actions: actions,
241
+ configs: {},
242
+ });
243
+
244
+ ns.and_then('connect', andActionFirst);
245
+ ns.and_then('connect', andActionSecond);
246
+
247
+ expect(() => ns.run('connect')).toThrowError();
248
+ });
249
+
250
+ test('ensure `or_else` has access to error', () => {
251
+ const actions = new Map();
252
+ actions.set('connect', () => {
253
+ throw new Error('Oops!');
254
+ });
255
+
256
+ const ns = new Namespace<{
257
+ connect: () => void;
258
+ }>(NAMESPACE, PROVIDER_ID, {
259
+ actions: actions,
260
+ configs: {},
261
+ });
262
+
263
+ ns.or_else('connect', (_ctx: any, err: any) => {
264
+ return err instanceof Error;
265
+ });
266
+
267
+ const result = ns.run('connect');
268
+ expect(result).toBe(true);
269
+ });
270
+
271
+ test('should call `or_else` sequentially.', () => {
272
+ const orActionFirst = vi.fn((_ctx, _err) => 1);
273
+ const orActionSecond = vi.fn((_ctx, _err) => _err + 1);
274
+
275
+ const connectAction = vi.fn(() => {
276
+ throw new Error('Oops!');
277
+ });
278
+
279
+ const actions = new Map();
280
+ actions.set('connect', connectAction);
281
+
282
+ const ns = new Namespace<{
283
+ connect: () => void;
284
+ }>(NAMESPACE, PROVIDER_ID, {
285
+ actions: actions,
286
+ });
287
+
288
+ ns.or_else('connect', orActionFirst);
289
+ ns.or_else('connect', orActionSecond);
290
+
291
+ const result = ns.run('connect');
292
+
293
+ expect(connectAction).toBeCalledTimes(1);
294
+ expect(orActionFirst).toBeCalledTimes(1);
295
+ expect(orActionSecond).toBeCalledTimes(1);
296
+
297
+ expect(result).toBe(2);
298
+
299
+ ns.run('connect');
300
+ expect(connectAction).toBeCalledTimes(2);
301
+ expect(orActionFirst).toBeCalledTimes(2);
302
+ expect(orActionSecond).toBeCalledTimes(2);
303
+ });
304
+ test('throw error if `or_else` itself failed to run.', () => {
305
+ const orActionFirst = vi.fn((_ctx, _err) => 1);
306
+ const orActionSecond = vi.fn((_ctx, _err) => {
307
+ throw new Error('This is actually a bad situation');
308
+ });
309
+
310
+ const connectAction = vi.fn(() => {
311
+ throw new Error('Oops!');
312
+ });
313
+
314
+ const actions = new Map();
315
+ actions.set('connect', connectAction);
316
+
317
+ const ns = new Namespace<{
318
+ connect: () => void;
319
+ }>(NAMESPACE, PROVIDER_ID, {
320
+ actions: actions,
321
+ });
322
+
323
+ ns.or_else('connect', orActionFirst);
324
+ ns.or_else('connect', orActionSecond);
325
+
326
+ expect(() => {
327
+ ns.run('connect');
328
+ }).toThrowError(OR_ELSE_ACTION_FAILED_ERROR('connect'));
329
+ expect(orActionFirst).toBeCalledTimes(1);
330
+ expect(connectAction).toBeCalledTimes(1);
331
+ expect(orActionSecond).toBeCalledTimes(1);
332
+ });
333
+ });