@notabene/javascript-sdk 2.1.0 → 2.2.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 (112) hide show
  1. package/README.md +24 -0
  2. package/dist/notabene.cjs +1 -1
  3. package/dist/notabene.d.ts +7 -0
  4. package/dist/notabene.js +101 -70
  5. package/docs/README.md +24 -0
  6. package/docs/_media/TransactionOptions.md +6 -6
  7. package/docs/ivms/types/enumerations/PayloadVersionCode.md +2 -2
  8. package/docs/ivms/types/interfaces/PayloadMetadata.md +2 -2
  9. package/docs/ivms/types/type-aliases/Address.md +1 -1
  10. package/docs/ivms/types/type-aliases/AddressTypeCode.md +1 -1
  11. package/docs/ivms/types/type-aliases/Beneficiary.md +1 -1
  12. package/docs/ivms/types/type-aliases/BeneficiaryVASP.md +1 -1
  13. package/docs/ivms/types/type-aliases/DateAndPlaceOfBirth.md +1 -1
  14. package/docs/ivms/types/type-aliases/ISOCountryCode.md +1 -1
  15. package/docs/ivms/types/type-aliases/ISODate.md +1 -1
  16. package/docs/ivms/types/type-aliases/IVMS101.md +1 -1
  17. package/docs/ivms/types/type-aliases/IntermediaryVASP.md +1 -1
  18. package/docs/ivms/types/type-aliases/LegalPerson.md +1 -1
  19. package/docs/ivms/types/type-aliases/LegalPersonName.md +1 -1
  20. package/docs/ivms/types/type-aliases/LegalPersonNameID.md +1 -1
  21. package/docs/ivms/types/type-aliases/LegalPersonNameTypeCode.md +1 -1
  22. package/docs/ivms/types/type-aliases/LocalLegalPersonNameID.md +1 -1
  23. package/docs/ivms/types/type-aliases/LocalNaturalPersonNameID.md +1 -1
  24. package/docs/ivms/types/type-aliases/NationalIdentification.md +1 -1
  25. package/docs/ivms/types/type-aliases/NationalIdentifierTypeCode.md +1 -1
  26. package/docs/ivms/types/type-aliases/NaturalPerson.md +1 -1
  27. package/docs/ivms/types/type-aliases/NaturalPersonName.md +1 -1
  28. package/docs/ivms/types/type-aliases/NaturalPersonNameID.md +1 -1
  29. package/docs/ivms/types/type-aliases/NaturalPersonNameTypeCode.md +1 -1
  30. package/docs/ivms/types/type-aliases/OriginatingVASP.md +1 -1
  31. package/docs/ivms/types/type-aliases/Originator.md +1 -1
  32. package/docs/ivms/types/type-aliases/Person.md +1 -1
  33. package/docs/ivms/types/type-aliases/TransferPath.md +1 -1
  34. package/docs/ivms/types/type-aliases/TransliterationMethodCode.md +1 -1
  35. package/docs/notabene/classes/EmbeddedComponent.md +39 -16
  36. package/docs/notabene/classes/default.md +6 -6
  37. package/docs/notabene/functions/decodeFragmentToObject.md +1 -1
  38. package/docs/notabene/interfaces/NotabeneConfig.md +5 -5
  39. package/docs/notabene/type-aliases/MessageCallback.md +1 -1
  40. package/docs/types/enumerations/AgentType.md +2 -2
  41. package/docs/types/enumerations/CMType.md +6 -6
  42. package/docs/types/enumerations/HMType.md +2 -2
  43. package/docs/types/enumerations/PersonType.md +3 -3
  44. package/docs/types/enumerations/ProofStatus.md +4 -4
  45. package/docs/types/enumerations/ProofTypes.md +12 -12
  46. package/docs/types/enumerations/Status.md +5 -5
  47. package/docs/types/enumerations/VASPSearchControl.md +2 -2
  48. package/docs/types/enumerations/ValidationSections.md +4 -4
  49. package/docs/types/interfaces/Agent.md +6 -6
  50. package/docs/types/interfaces/CallbackOptions.md +2 -2
  51. package/docs/types/interfaces/ComponentRequest.md +2 -2
  52. package/docs/types/interfaces/ComponentResponse.md +4 -4
  53. package/docs/types/interfaces/ConnectionRecord.md +7 -7
  54. package/docs/types/interfaces/ConnectionRequest.md +3 -3
  55. package/docs/types/interfaces/Counterparty.md +10 -10
  56. package/docs/types/interfaces/DeclarationProof.md +6 -6
  57. package/docs/types/interfaces/Deposit.md +9 -9
  58. package/docs/types/interfaces/DepositRequest.md +7 -7
  59. package/docs/types/interfaces/DepositRequestOptions.md +1 -1
  60. package/docs/types/interfaces/LegalPerson.md +13 -13
  61. package/docs/types/interfaces/MicroTransferProof.md +9 -9
  62. package/docs/types/interfaces/NaturalPerson.md +13 -13
  63. package/docs/types/interfaces/OwnershipProof.md +4 -4
  64. package/docs/types/interfaces/ScreenshotProof.md +5 -5
  65. package/docs/types/interfaces/SignatureProof.md +7 -7
  66. package/docs/types/interfaces/ThresholdOptions.md +3 -3
  67. package/docs/types/interfaces/Transaction.md +8 -8
  68. package/docs/types/interfaces/TransactionOptions.md +6 -6
  69. package/docs/types/interfaces/TransactionResponse.md +8 -8
  70. package/docs/types/interfaces/VASP.md +9 -9
  71. package/docs/types/interfaces/Wallet.md +8 -8
  72. package/docs/types/interfaces/Withdrawal.md +9 -9
  73. package/docs/types/type-aliases/BlockchainAddress.md +1 -1
  74. package/docs/types/type-aliases/CAIP10.md +1 -1
  75. package/docs/types/type-aliases/CAIP19.md +1 -1
  76. package/docs/types/type-aliases/CAIP2.md +1 -1
  77. package/docs/types/type-aliases/CAIP220.md +1 -1
  78. package/docs/types/type-aliases/Cancel.md +1 -1
  79. package/docs/types/type-aliases/Completed.md +1 -1
  80. package/docs/types/type-aliases/ComponentMessage.md +1 -1
  81. package/docs/types/type-aliases/ConnectionOptions.md +1 -1
  82. package/docs/types/type-aliases/CryptoCredential.md +1 -1
  83. package/docs/types/type-aliases/DID.md +1 -1
  84. package/docs/types/type-aliases/DTI.md +1 -1
  85. package/docs/types/type-aliases/Destination.md +1 -1
  86. package/docs/types/type-aliases/Error.md +1 -1
  87. package/docs/types/type-aliases/FieldOptions.md +1 -1
  88. package/docs/types/type-aliases/FieldTypes.md +1 -1
  89. package/docs/types/type-aliases/HostMessage.md +1 -1
  90. package/docs/types/type-aliases/ISOCurrency.md +1 -1
  91. package/docs/types/type-aliases/InvalidValue.md +1 -1
  92. package/docs/types/type-aliases/LEI.md +1 -1
  93. package/docs/types/type-aliases/LegalPersonFieldName.md +1 -1
  94. package/docs/types/type-aliases/LegalPersonFields.md +1 -1
  95. package/docs/types/type-aliases/NaturalPersonFieldName.md +1 -1
  96. package/docs/types/type-aliases/NaturalPersonFields.md +1 -1
  97. package/docs/types/type-aliases/NotabeneAsset.md +1 -1
  98. package/docs/types/type-aliases/ResizeRequest.md +1 -1
  99. package/docs/types/type-aliases/Source.md +1 -1
  100. package/docs/types/type-aliases/Theme.md +1 -1
  101. package/docs/types/type-aliases/TransactionAsset.md +1 -1
  102. package/docs/types/type-aliases/TravelAddress.md +1 -1
  103. package/docs/types/type-aliases/URI.md +1 -1
  104. package/docs/types/type-aliases/UUID.md +1 -1
  105. package/docs/types/type-aliases/UpdateValue.md +1 -1
  106. package/docs/types/type-aliases/V1Asset.md +1 -1
  107. package/docs/types/type-aliases/V1Transaction.md +1 -1
  108. package/docs/types/type-aliases/VASPOptions.md +1 -1
  109. package/docs/types/type-aliases/ValidationError.md +1 -1
  110. package/package.json +3 -4
  111. package/src/components/EmbeddedComponent.ts +49 -5
  112. package/src/components/__tests__/EmbeddedComponent.test.ts +0 -530
@@ -1,530 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
2
- import {
3
- AgentType,
4
- CMType,
5
- HMType,
6
- type HostMessage,
7
- type Transaction,
8
- type TransactionOptions,
9
- type Withdrawal,
10
- } from '../../types';
11
- import { MessageEventManager } from '../../utils/MessageEventManager';
12
- import EmbeddedComponent from '../EmbeddedComponent';
13
-
14
- const url = 'https://example.com';
15
- const parentId = 'parent-container';
16
- const value: Partial<Transaction> = { amountDecimal: 100 };
17
-
18
- describe('EmbeddedComponent', () => {
19
- describe('creation', () => {
20
- let component: EmbeddedComponent<Withdrawal, TransactionOptions>;
21
- beforeEach(() => {
22
- component = new EmbeddedComponent<Withdrawal, TransactionOptions>(url, {
23
- amountDecimal: 100,
24
- });
25
- });
26
-
27
- test('sets value', () => {
28
- expect(component.value).toStrictEqual(value);
29
- });
30
-
31
- test('sets url', () => {
32
- expect(component.url).toBe(url);
33
- });
34
- });
35
-
36
- describe('iframe', () => {
37
- let document: Document;
38
- let parentElement: HTMLElement;
39
- let iframe: HTMLIFrameElement;
40
- let window: Window;
41
-
42
- beforeEach(() => {
43
- parentElement = {
44
- appendChild: vi.fn(),
45
- } as unknown as HTMLElement;
46
-
47
- iframe = {
48
- style: {},
49
- src: '',
50
- contentWindow: {
51
- focus: vi.fn(),
52
- } as unknown as Window,
53
- remove: vi.fn(),
54
- setAttribute: vi.fn(),
55
- addEventListener: vi.fn(),
56
- } as unknown as HTMLIFrameElement;
57
-
58
- document = {
59
- createElement: vi.fn().mockReturnValue(iframe),
60
- querySelector: vi.fn().mockReturnValue(parentElement),
61
- } as unknown as Document;
62
-
63
- window = {
64
- addEventListener: vi.fn(),
65
- } as unknown as Window;
66
-
67
- vi.stubGlobal('document', document);
68
- vi.stubGlobal('window', window);
69
- });
70
-
71
- afterEach(() => {
72
- vi.unstubAllGlobals();
73
- });
74
-
75
- test('mount', () => {
76
- const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
77
- url,
78
- value,
79
- );
80
- component.mount(parentId);
81
- expect(iframe?.src).toBe(url + '&embedded=true');
82
- expect(parentElement.appendChild).toHaveBeenCalledWith(iframe);
83
- });
84
-
85
- test('on', () => {
86
- const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
87
- url,
88
- value,
89
- );
90
- const messageType = 'customEvent';
91
- const callback = vi.fn();
92
- component.on(messageType, callback);
93
- component.mount(parentId);
94
-
95
- // Simulate receiving a message of the specified type
96
- // and assert that the callback is called with the correct payload.
97
- });
98
-
99
- test('off', () => {
100
- const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
101
- url,
102
- value,
103
- );
104
- const messageType = 'customEvent';
105
- const callback = vi.fn();
106
- component.on(messageType, callback);
107
-
108
- // Simulate receiving a message of the specified type
109
- // and assert that the callback is called with the correct payload.
110
-
111
- component.off(messageType, callback);
112
-
113
- // Simulate receiving another message of the specified type
114
- // and assert that the callback is not called.
115
- });
116
-
117
- describe('connected to iframe', () => {
118
- let messageHandler: (event: MessageEvent) => void;
119
- let port: MessagePort;
120
- let handshake: MessageEvent;
121
- let component: EmbeddedComponent<Withdrawal, TransactionOptions>;
122
- let options: TransactionOptions;
123
-
124
- beforeEach(() => {
125
- port = {
126
- postMessage: vi.fn(),
127
- start: vi.fn(),
128
- onmessage: null,
129
- } as unknown as MessagePort;
130
- handshake = {
131
- source: iframe.contentWindow,
132
- ports: [port],
133
- } as unknown as MessageEvent;
134
- window.addEventListener = vi
135
- .fn()
136
- .mockImplementation((event, handler) => {
137
- messageHandler = handler;
138
- });
139
- options = { allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP] };
140
- component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
141
- url,
142
- value,
143
- options,
144
- );
145
- component.mount(parentId);
146
-
147
- expect(messageHandler).toBeDefined();
148
- messageHandler(handshake);
149
- });
150
-
151
- test('send', () => {
152
- const message: HostMessage<Withdrawal, TransactionOptions> = {
153
- type: HMType.UPDATE,
154
- value: {
155
- requestId: 'id',
156
- },
157
- options: { allowedAgentTypes: [AgentType.PRIVATE] },
158
- };
159
- component.send(message);
160
- expect(port.postMessage).toHaveBeenCalledWith(message);
161
- });
162
-
163
- describe('update', () => {
164
- test('with out options', () => {
165
- const newValue: Partial<Transaction> = { amountDecimal: 200 };
166
-
167
- const message: HostMessage<Withdrawal, TransactionOptions> = {
168
- type: HMType.UPDATE,
169
- value: newValue,
170
- options,
171
- };
172
-
173
- component.update(newValue);
174
-
175
- expect(component.value).toBe(newValue);
176
- expect(component.options).toBe(options);
177
- expect(port.postMessage).toHaveBeenCalledWith(message);
178
- });
179
-
180
- test('with options', () => {
181
- const newValue: Partial<Transaction> = { amountDecimal: 200 };
182
- const newOptions = { allowedAgentTypes: [AgentType.PRIVATE] };
183
-
184
- const message: HostMessage<Withdrawal, TransactionOptions> = {
185
- type: HMType.UPDATE,
186
- value: newValue,
187
- options: newOptions,
188
- };
189
-
190
- component.update(newValue, newOptions);
191
-
192
- expect(component.value).toBe(newValue);
193
- expect(component.options).toBe(newOptions);
194
- expect(port.postMessage).toHaveBeenCalledWith(message);
195
- });
196
- });
197
- // TODO not sure this actually does what I want it to do
198
- describe('completion', () => {
199
- test('resolves with response and cleans up listeners', async () => {
200
- const response = { valid: true, value: 'completed' };
201
- const completionPromise = component.completion();
202
-
203
- port.onmessage!({
204
- data: { type: CMType.COMPLETE, response },
205
- } as unknown as MessageEvent);
206
-
207
- const result = await completionPromise;
208
- expect(result).toBe(response);
209
-
210
- // Verify cleanup by sending another complete message - should not trigger anything
211
- port.onmessage!({
212
- data: { type: CMType.COMPLETE, response: { valid: false } },
213
- } as unknown as MessageEvent);
214
-
215
- // Original result should remain unchanged
216
- expect(result).toBe(response);
217
- });
218
-
219
- test('rejects with error and cleans up listeners', async () => {
220
- const errorMessage = 'Test error';
221
- const completionPromise = component.completion();
222
-
223
- port.onmessage!({
224
- data: { type: 'error', message: errorMessage },
225
- } as unknown as MessageEvent);
226
-
227
- await expect(completionPromise).rejects.toThrow(errorMessage);
228
-
229
- // Verify cleanup by sending another error - should not trigger anything
230
- port.onmessage!({
231
- data: { type: 'error', message: 'Different error' },
232
- } as unknown as MessageEvent);
233
-
234
- // Original rejection should remain
235
- await expect(completionPromise).rejects.toThrow(errorMessage);
236
- });
237
- });
238
- });
239
- });
240
-
241
- describe('modal', () => {
242
- let document: Document;
243
- let dialog: HTMLDialogElement;
244
- let component: EmbeddedComponent<Withdrawal, TransactionOptions>;
245
-
246
- beforeEach(() => {
247
- dialog = {
248
- style: {},
249
- showModal: vi.fn(),
250
- close: vi.fn(),
251
- remove: vi.fn(),
252
- addEventListener: vi.fn(),
253
- appendChild: vi.fn(), // Add this
254
- } as unknown as HTMLDialogElement;
255
-
256
- document = {
257
- createElement: vi.fn().mockImplementation((tag) => {
258
- if (tag === 'dialog') return dialog;
259
- if (tag === 'iframe')
260
- return {
261
- style: {},
262
- contentWindow: { focus: vi.fn() },
263
- addEventListener: vi.fn(),
264
- } as unknown as HTMLIFrameElement;
265
- }),
266
- body: {
267
- appendChild: vi.fn(),
268
- },
269
- } as unknown as Document;
270
-
271
- const mockDoc = document;
272
- vi.stubGlobal('document', mockDoc); // Use intermediate variable
273
-
274
- component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
275
- url,
276
- value,
277
- );
278
- });
279
-
280
- afterEach(() => {
281
- vi.unstubAllGlobals();
282
- });
283
-
284
- test('modal closes on cancel message', () => {
285
- component.openModal();
286
-
287
- // Trigger cancel message through event manager
288
- component['eventManager']['handleMessage']({
289
- data: { type: CMType.CANCEL },
290
- } as MessageEvent);
291
-
292
- expect(dialog.close).toHaveBeenCalled();
293
- expect(dialog.remove).toHaveBeenCalled();
294
- // await expect(completionPromise).rejects.toThrow();
295
- });
296
-
297
- test('modal closes on completion', async () => {
298
- const completionPromise = component.openModal();
299
- const response = { valid: true, value: 'completed' };
300
-
301
- // Trigger complete message through event manager
302
- component['eventManager']['handleMessage']({
303
- data: { type: CMType.COMPLETE, response },
304
- } as MessageEvent);
305
-
306
- expect(dialog.close).toHaveBeenCalled();
307
- expect(dialog.remove).toHaveBeenCalled();
308
- await expect(completionPromise).resolves.toBe(response);
309
- });
310
- });
311
-
312
- describe('error handling', () => {
313
- let component: EmbeddedComponent<Withdrawal, TransactionOptions>;
314
- let mockMessageManager: (typeof component)['eventManager'];
315
- let document: Document;
316
- let parentElement: HTMLElement;
317
-
318
- beforeEach(() => {
319
- parentElement = {
320
- appendChild: vi.fn(),
321
- } as unknown as HTMLElement;
322
-
323
- document = {
324
- createElement: vi.fn().mockReturnValue({
325
- style: {},
326
- contentWindow: { focus: vi.fn() },
327
- } as unknown as HTMLIFrameElement),
328
- querySelector: vi.fn().mockReturnValue(parentElement),
329
- } as unknown as Document;
330
-
331
- const mockDoc = document;
332
- vi.stubGlobal('document', mockDoc);
333
-
334
- component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
335
- url,
336
- value,
337
- );
338
- mockMessageManager = component['eventManager'];
339
- });
340
-
341
- test('handles invalid messages', () => {
342
- const errors = [{ attribute: 'test', message: 'error' }];
343
- const newValue = { ...value, extra: 'data' };
344
-
345
- mockMessageManager['handleMessage']({
346
- data: {
347
- type: CMType.INVALID,
348
- errors,
349
- value: newValue,
350
- },
351
- } as MessageEvent);
352
-
353
- expect(component.errors).toEqual(errors);
354
- expect(component.value).toEqual(newValue);
355
- });
356
-
357
- test('handles resize messages', () => {
358
- const mockIframe = {
359
- style: {},
360
- contentWindow: { focus: vi.fn() },
361
- } as unknown as HTMLIFrameElement;
362
-
363
- document.createElement = vi.fn().mockReturnValue(mockIframe);
364
- document.querySelector = vi.fn().mockReturnValue(parentElement);
365
-
366
- component.mount(parentId);
367
-
368
- mockMessageManager['handleMessage']({
369
- data: {
370
- type: CMType.RESIZE,
371
- height: 500,
372
- },
373
- } as MessageEvent);
374
-
375
- expect(mockIframe.style.height).toBe('500px');
376
- });
377
- });
378
-
379
- describe('event management', () => {
380
- let component: EmbeddedComponent<Withdrawal, TransactionOptions>;
381
- let mockWindow: Window;
382
- beforeEach(() => {
383
- // Create a mock window without modifying global
384
- mockWindow = {
385
- addEventListener: vi.fn(),
386
- dispatchEvent: vi.fn(),
387
- } as unknown as Window;
388
-
389
- vi.stubGlobal('window', mockWindow);
390
-
391
- component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
392
- url,
393
- value,
394
- );
395
- });
396
-
397
- afterEach(() => {
398
- vi.unstubAllGlobals();
399
- });
400
-
401
- test('multiple listeners for same event type', () => {
402
- const callback1 = vi.fn();
403
- const callback2 = vi.fn();
404
-
405
- component.on('test', callback1);
406
- component.on('test', callback2);
407
-
408
- // Trigger message via component's event manager
409
- component['eventManager']['handleMessage']({
410
- data: { type: 'test', payload: 'data' },
411
- } as MessageEvent);
412
-
413
- expect(callback1).toHaveBeenCalled();
414
- expect(callback2).toHaveBeenCalled();
415
- });
416
-
417
- test('removal of specific listener', () => {
418
- const callback1 = vi.fn();
419
- const callback2 = vi.fn();
420
-
421
- component.on('test', callback1);
422
- component.on('test', callback2);
423
- component.off('test', callback1);
424
-
425
- component['eventManager']['handleMessage']({
426
- data: { type: 'test', payload: 'data' },
427
- } as MessageEvent);
428
-
429
- expect(callback1).not.toHaveBeenCalled();
430
- expect(callback2).toHaveBeenCalled();
431
- });
432
- });
433
-
434
- describe('cleanup', () => {
435
- let mockIframe: HTMLIFrameElement;
436
- let parentElement: HTMLElement;
437
- let document: Document;
438
-
439
- beforeEach(() => {
440
- mockIframe = {
441
- style: {},
442
- src: '',
443
- contentWindow: {
444
- focus: vi.fn(),
445
- } as unknown as Window,
446
- remove: vi.fn(),
447
- } as unknown as HTMLIFrameElement;
448
-
449
- parentElement = {
450
- appendChild: vi.fn(),
451
- } as unknown as HTMLElement;
452
-
453
- document = {
454
- createElement: vi.fn().mockReturnValue(mockIframe),
455
- querySelector: vi.fn().mockReturnValue(parentElement),
456
- } as unknown as Document;
457
-
458
- const mockDoc = document;
459
- vi.stubGlobal('document', mockDoc);
460
- });
461
-
462
- afterEach(() => {
463
- vi.unstubAllGlobals();
464
- });
465
-
466
- test('removeEmbed cleans up iframe', () => {
467
- const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
468
- url,
469
- value,
470
- );
471
- component.mount(parentId);
472
-
473
- component.removeEmbed();
474
- expect(mockIframe.remove).toHaveBeenCalled();
475
- });
476
-
477
- test('cleanup on unmount', () => {
478
- const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
479
- url,
480
- value,
481
- );
482
- const callback = vi.fn();
483
- component.on('test', callback);
484
-
485
- component.mount(parentId);
486
-
487
- component.removeEmbed();
488
-
489
- // Create a new event manager to simulate cleanup
490
- component['eventManager'] = new MessageEventManager();
491
-
492
- // Try to trigger message after cleanup
493
- component['eventManager']['handleMessage']({
494
- data: { type: 'test', payload: 'data' },
495
- } as MessageEvent);
496
-
497
- expect(callback).not.toHaveBeenCalled();
498
- });
499
- });
500
-
501
- describe('state management', () => {
502
- test('maintains value and options state', () => {
503
- const initialValue = { amountDecimal: 100 };
504
- const initialOptions = { allowedAgentTypes: [AgentType.PRIVATE] };
505
-
506
- const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
507
- url,
508
- initialValue,
509
- initialOptions,
510
- );
511
-
512
- expect(component.value).toEqual(initialValue);
513
- expect(component.options).toEqual(initialOptions);
514
- });
515
-
516
- test('updates maintain state consistency', () => {
517
- const component = new EmbeddedComponent<Withdrawal, TransactionOptions>(
518
- url,
519
- value,
520
- );
521
- const newValue = { amountDecimal: 200 };
522
- const newOptions = { allowedAgentTypes: [AgentType.VASP] };
523
-
524
- component.update(newValue, newOptions);
525
-
526
- expect(component.value).toEqual(newValue);
527
- expect(component.options).toEqual(newOptions);
528
- });
529
- });
530
- });