@blac/core 2.0.0-rc-16 → 2.0.0-rc.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 (157) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/Blac.d.ts +246 -0
  3. package/dist/Blac.d.ts.map +1 -0
  4. package/dist/Blac.js +625 -0
  5. package/dist/Blac.js.map +1 -0
  6. package/dist/Bloc.d.ts +41 -0
  7. package/dist/Bloc.d.ts.map +1 -0
  8. package/dist/Bloc.js +140 -0
  9. package/dist/Bloc.js.map +1 -0
  10. package/dist/BlocBase.d.ts +110 -0
  11. package/dist/BlocBase.d.ts.map +1 -0
  12. package/dist/BlocBase.js +287 -0
  13. package/dist/BlocBase.js.map +1 -0
  14. package/dist/Cubit.d.ts +25 -0
  15. package/dist/Cubit.d.ts.map +1 -0
  16. package/dist/Cubit.js +64 -0
  17. package/dist/Cubit.js.map +1 -0
  18. package/dist/adapter/BlacAdapter.d.ts +71 -0
  19. package/dist/adapter/BlacAdapter.d.ts.map +1 -0
  20. package/dist/adapter/BlacAdapter.js +373 -0
  21. package/dist/adapter/BlacAdapter.js.map +1 -0
  22. package/dist/adapter/ProxyFactory.d.ts +50 -0
  23. package/dist/adapter/ProxyFactory.d.ts.map +1 -0
  24. package/dist/adapter/ProxyFactory.js +150 -0
  25. package/dist/adapter/ProxyFactory.js.map +1 -0
  26. package/{src/adapter/index.ts → dist/adapter/index.d.ts} +1 -0
  27. package/dist/adapter/index.d.ts.map +1 -0
  28. package/dist/adapter/index.js +19 -0
  29. package/dist/adapter/index.js.map +1 -0
  30. package/dist/errors/BlacError.d.ts +38 -0
  31. package/dist/errors/BlacError.d.ts.map +1 -0
  32. package/dist/errors/BlacError.js +55 -0
  33. package/dist/errors/BlacError.js.map +1 -0
  34. package/dist/errors/ErrorManager.d.ts +39 -0
  35. package/dist/errors/ErrorManager.d.ts.map +1 -0
  36. package/dist/errors/ErrorManager.js +91 -0
  37. package/dist/errors/ErrorManager.js.map +1 -0
  38. package/dist/errors/handleError.d.ts +24 -0
  39. package/dist/errors/handleError.d.ts.map +1 -0
  40. package/dist/errors/handleError.js +62 -0
  41. package/dist/errors/handleError.js.map +1 -0
  42. package/dist/errors/index.d.ts +5 -0
  43. package/dist/errors/index.d.ts.map +1 -0
  44. package/dist/errors/index.js +13 -0
  45. package/dist/errors/index.js.map +1 -0
  46. package/{src/events.ts → dist/events.d.ts} +4 -2
  47. package/dist/events.d.ts.map +1 -0
  48. package/dist/events.js +17 -0
  49. package/dist/events.js.map +1 -0
  50. package/dist/index.cjs +38 -0
  51. package/{src/index.ts → dist/index.d.ts} +1 -10
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +38 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/lifecycle/BlocLifecycle.d.ts +51 -0
  56. package/dist/lifecycle/BlocLifecycle.d.ts.map +1 -0
  57. package/dist/lifecycle/BlocLifecycle.js +123 -0
  58. package/dist/lifecycle/BlocLifecycle.js.map +1 -0
  59. package/dist/lifecycle/index.d.ts +2 -0
  60. package/dist/lifecycle/index.d.ts.map +1 -0
  61. package/dist/lifecycle/index.js +18 -0
  62. package/dist/lifecycle/index.js.map +1 -0
  63. package/dist/plugins/BlocPluginRegistry.d.ts +58 -0
  64. package/dist/plugins/BlocPluginRegistry.d.ts.map +1 -0
  65. package/dist/plugins/BlocPluginRegistry.js +201 -0
  66. package/dist/plugins/BlocPluginRegistry.js.map +1 -0
  67. package/dist/plugins/SystemPluginRegistry.d.ts +79 -0
  68. package/dist/plugins/SystemPluginRegistry.d.ts.map +1 -0
  69. package/dist/plugins/SystemPluginRegistry.js +184 -0
  70. package/dist/plugins/SystemPluginRegistry.js.map +1 -0
  71. package/{src/plugins/index.ts → dist/plugins/index.d.ts} +1 -5
  72. package/dist/plugins/index.d.ts.map +1 -0
  73. package/dist/plugins/index.js +26 -0
  74. package/dist/plugins/index.js.map +1 -0
  75. package/dist/plugins/types.d.ts +103 -0
  76. package/dist/plugins/types.d.ts.map +1 -0
  77. package/dist/plugins/types.js +3 -0
  78. package/dist/plugins/types.js.map +1 -0
  79. package/dist/subscription/SubscriptionManager.d.ts +67 -0
  80. package/dist/subscription/SubscriptionManager.d.ts.map +1 -0
  81. package/dist/subscription/SubscriptionManager.js +317 -0
  82. package/dist/subscription/SubscriptionManager.js.map +1 -0
  83. package/{src/subscription/index.ts → dist/subscription/index.d.ts} +1 -0
  84. package/dist/subscription/index.d.ts.map +1 -0
  85. package/dist/subscription/index.js +19 -0
  86. package/dist/subscription/index.js.map +1 -0
  87. package/dist/subscription/types.d.ts +65 -0
  88. package/dist/subscription/types.d.ts.map +1 -0
  89. package/dist/subscription/types.js +3 -0
  90. package/dist/subscription/types.js.map +1 -0
  91. package/dist/testing.d.ts +85 -0
  92. package/dist/testing.d.ts.map +1 -0
  93. package/dist/testing.js +186 -0
  94. package/dist/testing.js.map +1 -0
  95. package/{src/types.ts → dist/types.d.ts} +11 -28
  96. package/dist/types.d.ts.map +1 -0
  97. package/dist/types.js +3 -0
  98. package/dist/types.js.map +1 -0
  99. package/dist/utils/BatchingManager.d.ts +28 -0
  100. package/dist/utils/BatchingManager.d.ts.map +1 -0
  101. package/dist/utils/BatchingManager.js +48 -0
  102. package/dist/utils/BatchingManager.js.map +1 -0
  103. package/dist/utils/RerenderLogger.d.ts +60 -0
  104. package/dist/utils/RerenderLogger.d.ts.map +1 -0
  105. package/dist/utils/RerenderLogger.js +205 -0
  106. package/dist/utils/RerenderLogger.js.map +1 -0
  107. package/dist/utils/generateInstanceId.d.ts +11 -0
  108. package/dist/utils/generateInstanceId.d.ts.map +1 -0
  109. package/dist/utils/generateInstanceId.js +50 -0
  110. package/dist/utils/generateInstanceId.js.map +1 -0
  111. package/dist/utils/shallowEqual.d.ts +9 -0
  112. package/dist/utils/shallowEqual.d.ts.map +1 -0
  113. package/dist/utils/shallowEqual.js +35 -0
  114. package/dist/utils/shallowEqual.js.map +1 -0
  115. package/dist/utils/uuid.d.ts +10 -0
  116. package/dist/utils/uuid.d.ts.map +1 -0
  117. package/dist/utils/uuid.js +24 -0
  118. package/dist/utils/uuid.js.map +1 -0
  119. package/package.json +17 -6
  120. package/src/Blac.ts +0 -802
  121. package/src/Bloc.ts +0 -180
  122. package/src/BlocBase.ts +0 -398
  123. package/src/Cubit.ts +0 -68
  124. package/src/__tests__/Blac.config.test.ts +0 -79
  125. package/src/__tests__/Bloc.event.test.ts +0 -394
  126. package/src/__tests__/BlocBase.subscription.test.ts +0 -349
  127. package/src/__tests__/Cubit.test.ts +0 -462
  128. package/src/__tests__/memory-leaks.test.ts +0 -383
  129. package/src/__tests__/plugins.test.ts +0 -464
  130. package/src/adapter/BlacAdapter.ts +0 -467
  131. package/src/adapter/ProxyFactory.ts +0 -249
  132. package/src/adapter/__tests__/BlacAdapter.test.ts +0 -555
  133. package/src/adapter/__tests__/ProxyFactory.test.ts +0 -655
  134. package/src/errors/BlacError.ts +0 -69
  135. package/src/errors/ErrorManager.ts +0 -101
  136. package/src/errors/handleError.ts +0 -114
  137. package/src/errors/index.ts +0 -13
  138. package/src/lifecycle/BlocLifecycle.ts +0 -156
  139. package/src/lifecycle/index.ts +0 -1
  140. package/src/plugins/BlocPluginRegistry.ts +0 -240
  141. package/src/plugins/SystemPluginRegistry.ts +0 -242
  142. package/src/plugins/__tests__/BlocPluginRegistry.test.ts +0 -450
  143. package/src/plugins/__tests__/SystemPluginRegistry.test.ts +0 -404
  144. package/src/plugins/types.ts +0 -129
  145. package/src/subscription/README.md +0 -132
  146. package/src/subscription/SubscriptionManager.ts +0 -395
  147. package/src/subscription/__tests__/SubscriptionManager.test.ts +0 -355
  148. package/src/subscription/types.ts +0 -90
  149. package/src/testing.ts +0 -246
  150. package/src/utils/BatchingManager.ts +0 -59
  151. package/src/utils/RerenderLogger.ts +0 -265
  152. package/src/utils/__tests__/generateInstanceId.test.ts +0 -104
  153. package/src/utils/__tests__/shallowEqual.test.ts +0 -171
  154. package/src/utils/__tests__/uuid.test.ts +0 -144
  155. package/src/utils/generateInstanceId.ts +0 -54
  156. package/src/utils/shallowEqual.ts +0 -40
  157. package/src/utils/uuid.ts +0 -22
@@ -1,464 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { Blac } from '../Blac';
3
- import { Cubit } from '../Cubit';
4
- import { Bloc } from '../Bloc';
5
- import { BlacPlugin, BlocPlugin, PluginCapabilities } from '../plugins';
6
- import { BlocBase } from '../BlocBase';
7
-
8
- // Test Cubit
9
- class CounterCubit extends Cubit<number> {
10
- constructor() {
11
- super(0);
12
- }
13
-
14
- increment = () => this.emit(this.state + 1);
15
- decrement = () => this.emit(this.state - 1);
16
- setValue = (value: number) => this.emit(value);
17
- }
18
-
19
- // Test Bloc
20
- abstract class CounterEvent {}
21
- class Increment extends CounterEvent {}
22
- class Decrement extends CounterEvent {}
23
- class SetValue extends CounterEvent {
24
- constructor(public value: number) {
25
- super();
26
- }
27
- }
28
-
29
- class CounterBloc extends Bloc<number, CounterEvent> {
30
- constructor() {
31
- super(0);
32
-
33
- this.on(Increment, (event, emit) => emit(this.state + 1));
34
- this.on(Decrement, (event, emit) => emit(this.state - 1));
35
- this.on(SetValue, (event, emit) => emit(event.value));
36
- }
37
- }
38
-
39
- // Test implementations of plugins
40
- class TestLoggingPlugin implements BlacPlugin {
41
- readonly name = 'logging';
42
- readonly version = '1.0.0';
43
- private logLevel: 'debug' | 'info' | 'warn' | 'error';
44
-
45
- constructor(
46
- options: { logLevel?: 'debug' | 'info' | 'warn' | 'error' } = {},
47
- ) {
48
- this.logLevel = options.logLevel || 'info';
49
- }
50
-
51
- onBlocCreated(bloc: BlocBase<any>): void {
52
- this.log('debug', `Bloc created: ${bloc._name}:${bloc._id}`);
53
- }
54
-
55
- onStateChanged(
56
- bloc: BlocBase<any>,
57
- previousState: any,
58
- currentState: any,
59
- ): void {
60
- this.log('debug', `State changed in ${bloc._name}:${bloc._id}`, {
61
- previousState,
62
- currentState,
63
- });
64
- }
65
-
66
- private log(
67
- level: 'debug' | 'info' | 'warn' | 'error',
68
- message: string,
69
- data?: any,
70
- ): void {
71
- const levels = ['debug', 'info', 'warn', 'error'];
72
- const currentLevelIndex = levels.indexOf(this.logLevel);
73
- const messageLevelIndex = levels.indexOf(level);
74
-
75
- if (messageLevelIndex >= currentLevelIndex) {
76
- const timestamp = new Date().toISOString();
77
- const logMessage = `[BlaC] [${timestamp}] ${message}`;
78
-
79
- switch (level) {
80
- case 'debug':
81
- console.debug(logMessage, data);
82
- break;
83
- case 'info':
84
- console.log(logMessage, data);
85
- break;
86
- case 'warn':
87
- console.warn(logMessage, data);
88
- break;
89
- case 'error':
90
- console.error(logMessage, data);
91
- break;
92
- }
93
- }
94
- }
95
- }
96
-
97
- interface StorageAdapter {
98
- getItem(key: string): string | null;
99
- setItem(key: string, value: string): void;
100
- removeItem(key: string): void;
101
- }
102
-
103
- class TestPersistencePlugin<TState> implements BlocPlugin<TState> {
104
- readonly name = 'persistence';
105
- readonly version = '1.0.0';
106
- readonly capabilities: PluginCapabilities = {
107
- readState: true,
108
- transformState: true,
109
- interceptEvents: false,
110
- persistData: true,
111
- accessMetadata: false,
112
- };
113
-
114
- private storage: StorageAdapter;
115
- private key: string;
116
- private saveDebounceMs: number;
117
- private saveTimer?: any;
118
-
119
- constructor(options: {
120
- key: string;
121
- storage?: StorageAdapter;
122
- saveDebounceMs?: number;
123
- }) {
124
- this.key = options.key;
125
- this.storage = options.storage || new MockStorage();
126
- this.saveDebounceMs = options.saveDebounceMs ?? 100;
127
- }
128
-
129
- onAttach(bloc: BlocBase<TState>): void {
130
- const savedData = this.storage.getItem(this.key);
131
- if (savedData) {
132
- const restoredState = JSON.parse(savedData);
133
- (bloc as any)._state = restoredState;
134
- }
135
- }
136
-
137
- onStateChange(previousState: TState, currentState: TState): void {
138
- if (this.saveTimer) {
139
- clearTimeout(this.saveTimer);
140
- }
141
-
142
- if (this.saveDebounceMs > 0) {
143
- this.saveTimer = setTimeout(() => {
144
- this.storage.setItem(this.key, JSON.stringify(currentState));
145
- }, this.saveDebounceMs);
146
- } else {
147
- this.storage.setItem(this.key, JSON.stringify(currentState));
148
- }
149
- }
150
- }
151
-
152
- class TestValidationPlugin<T> implements BlocPlugin<T> {
153
- readonly name = 'validation';
154
- readonly version = '1.0.0';
155
- readonly capabilities: PluginCapabilities = {
156
- readState: true,
157
- transformState: true,
158
- interceptEvents: false,
159
- persistData: false,
160
- accessMetadata: false,
161
- };
162
-
163
- constructor(private validator: (state: T) => boolean | string) {}
164
-
165
- transformState(previousState: T, nextState: T): T {
166
- const result = this.validator(nextState);
167
-
168
- if (result === true) {
169
- return nextState;
170
- } else if (result === false) {
171
- console.warn('State change rejected by validation plugin');
172
- return previousState;
173
- } else {
174
- console.error(`State validation failed: ${result}`);
175
- return previousState;
176
- }
177
- }
178
- }
179
-
180
- // Mock storage
181
- class MockStorage implements StorageAdapter {
182
- private store = new Map<string, string>();
183
-
184
- getItem(key: string): string | null {
185
- return this.store.get(key) || null;
186
- }
187
-
188
- setItem(key: string, value: string): void {
189
- this.store.set(key, value);
190
- }
191
-
192
- removeItem(key: string): void {
193
- this.store.delete(key);
194
- }
195
- }
196
-
197
- describe('New Plugin System', () => {
198
- beforeEach(() => {
199
- Blac.resetInstance();
200
- });
201
-
202
- describe('System Plugins (BlacPlugin)', () => {
203
- it('should register and execute system plugins', () => {
204
- const onBlocCreated = vi.fn();
205
- const onStateChanged = vi.fn();
206
-
207
- const plugin: BlacPlugin = {
208
- name: 'test-system-plugin',
209
- version: '1.0.0',
210
- onBlocCreated,
211
- onStateChanged,
212
- };
213
-
214
- Blac.instance.plugins.add(plugin);
215
-
216
- const cubit = Blac.getBloc(CounterCubit);
217
- expect(onBlocCreated).toHaveBeenCalledWith(cubit);
218
-
219
- cubit.increment();
220
- expect(onStateChanged).toHaveBeenCalledWith(cubit, 0, 1);
221
- });
222
-
223
- it('should handle plugin errors gracefully', () => {
224
- const errorPlugin: BlacPlugin = {
225
- name: 'error-plugin',
226
- version: '1.0.0',
227
- onBlocCreated: () => {
228
- throw new Error('Plugin error');
229
- },
230
- };
231
-
232
- Blac.instance.plugins.add(errorPlugin);
233
-
234
- // Should not throw when creating bloc
235
- expect(() => Blac.getBloc(CounterCubit)).not.toThrow();
236
- });
237
-
238
- it('should execute bootstrap hooks', () => {
239
- const beforeBootstrap = vi.fn();
240
- const afterBootstrap = vi.fn();
241
-
242
- const plugin: BlacPlugin = {
243
- name: 'bootstrap-plugin',
244
- version: '1.0.0',
245
- beforeBootstrap,
246
- afterBootstrap,
247
- };
248
-
249
- Blac.resetInstance();
250
- Blac.instance.plugins.add(plugin);
251
- Blac.instance.bootstrap();
252
-
253
- expect(beforeBootstrap).toHaveBeenCalled();
254
- expect(afterBootstrap).toHaveBeenCalled();
255
- });
256
-
257
- it('should track metrics', () => {
258
- const plugin: BlacPlugin = {
259
- name: 'metrics-plugin',
260
- version: '1.0.0',
261
- onBlocCreated: () => {
262
- // Do something
263
- },
264
- };
265
-
266
- Blac.instance.plugins.add(plugin);
267
- Blac.getBloc(CounterCubit);
268
-
269
- const metrics = Blac.instance.plugins.getMetrics('metrics-plugin');
270
- expect(metrics).toBeDefined();
271
- expect(metrics?.get('onBlocCreated')).toBeDefined();
272
- expect(metrics?.get('onBlocCreated')?.executionCount).toBe(1);
273
- });
274
- });
275
-
276
- describe('Bloc Plugins (BlocPlugin)', () => {
277
- it('should attach plugins to specific blocs', () => {
278
- const onAttach = vi.fn();
279
- const onStateChange = vi.fn();
280
-
281
- const plugin: BlocPlugin<number> = {
282
- name: 'test-bloc-plugin',
283
- version: '1.0.0',
284
- onAttach,
285
- onStateChange,
286
- };
287
-
288
- const cubit = new CounterCubit();
289
- cubit.addPlugin(plugin);
290
-
291
- // Activate the bloc
292
- Blac.activateBloc(cubit as any);
293
-
294
- expect(onAttach).toHaveBeenCalledWith(cubit);
295
-
296
- cubit.increment();
297
- expect(onStateChange).toHaveBeenCalledWith(0, 1);
298
- });
299
-
300
- it('should transform state through plugins', () => {
301
- const transformPlugin: BlocPlugin<number> = {
302
- name: 'double-plugin',
303
- version: '1.0.0',
304
- transformState: (prev, next) => next * 2,
305
- };
306
-
307
- const cubit = new CounterCubit();
308
- cubit.addPlugin(transformPlugin);
309
- Blac.activateBloc(cubit as any);
310
-
311
- cubit.setValue(5);
312
- expect(cubit.state).toBe(10); // 5 * 2
313
- });
314
-
315
- it('should transform events through plugins', () => {
316
- const transformPlugin: BlocPlugin<number, CounterEvent> = {
317
- name: 'event-doubler',
318
- version: '1.0.0',
319
- transformEvent: (event) => {
320
- if (event instanceof SetValue) {
321
- return new SetValue(event.value * 2);
322
- }
323
- return event;
324
- },
325
- };
326
-
327
- const bloc = new CounterBloc();
328
- bloc.addPlugin(transformPlugin);
329
- Blac.activateBloc(bloc as any);
330
-
331
- bloc.add(new SetValue(5));
332
-
333
- // Wait for event processing
334
- setTimeout(() => {
335
- expect(bloc.state).toBe(10); // 5 * 2
336
- }, 10);
337
- });
338
-
339
- it('should respect plugin capabilities', () => {
340
- const readOnlyPlugin: BlocPlugin<number> = {
341
- name: 'read-only',
342
- version: '1.0.0',
343
- capabilities: {
344
- readState: true,
345
- transformState: false,
346
- interceptEvents: false,
347
- persistData: false,
348
- accessMetadata: false,
349
- },
350
- transformState: () => {
351
- throw new Error('Should not be called');
352
- },
353
- onStateChange: vi.fn(),
354
- };
355
-
356
- const cubit = new CounterCubit();
357
- cubit.addPlugin(readOnlyPlugin);
358
- Blac.activateBloc(cubit as any);
359
-
360
- cubit.increment();
361
- expect(cubit.state).toBe(1); // Transform not applied
362
- expect(readOnlyPlugin.onStateChange).toHaveBeenCalled();
363
- });
364
- });
365
-
366
- describe('Example Plugins', () => {
367
- it('should log with TestLoggingPlugin', () => {
368
- const consoleSpy = vi.spyOn(console, 'debug');
369
-
370
- const plugin = new TestLoggingPlugin({ logLevel: 'debug' });
371
- Blac.instance.plugins.add(plugin);
372
-
373
- const cubit = Blac.getBloc(CounterCubit);
374
- cubit.increment();
375
-
376
- expect(consoleSpy).toHaveBeenCalledWith(
377
- expect.stringContaining('Bloc created'),
378
- undefined,
379
- );
380
-
381
- consoleSpy.mockRestore();
382
- });
383
-
384
- it('should persist state with TestPersistencePlugin', () => {
385
- const storage = new MockStorage();
386
- storage.setItem('counter', '42');
387
-
388
- const plugin = new TestPersistencePlugin<number>({
389
- key: 'counter',
390
- storage,
391
- saveDebounceMs: 0,
392
- });
393
-
394
- const cubit = new CounterCubit();
395
- cubit.addPlugin(plugin);
396
- Blac.activateBloc(cubit as any);
397
-
398
- // Should restore from storage
399
- expect(cubit.state).toBe(42);
400
-
401
- // Should save new state
402
- cubit.setValue(100);
403
-
404
- // Wait for debounced save
405
- setTimeout(() => {
406
- expect(storage.getItem('counter')).toBe('100');
407
- }, 10);
408
- });
409
-
410
- it('should validate state with TestValidationPlugin', () => {
411
- const validator = (state: number) => {
412
- if (state < 0) return 'Value must be non-negative';
413
- if (state > 100) return 'Value must not exceed 100';
414
- return true;
415
- };
416
-
417
- const plugin = new TestValidationPlugin(validator);
418
-
419
- const cubit = new CounterCubit();
420
- cubit.addPlugin(plugin);
421
- Blac.activateBloc(cubit as any);
422
-
423
- cubit.setValue(-5);
424
- expect(cubit.state).toBe(0); // Rejected
425
-
426
- cubit.setValue(50);
427
- expect(cubit.state).toBe(50); // Accepted
428
-
429
- cubit.setValue(150);
430
- expect(cubit.state).toBe(50); // Rejected
431
- });
432
- });
433
-
434
- describe('Plugin Composition', () => {
435
- it('should compose multiple bloc plugins', () => {
436
- const storage = new MockStorage();
437
-
438
- const persistencePlugin = new TestPersistencePlugin<number>({
439
- key: 'validated-counter',
440
- storage,
441
- saveDebounceMs: 0,
442
- });
443
-
444
- const validationPlugin = new TestValidationPlugin<number>(
445
- (state) => state >= 0 && state <= 10,
446
- );
447
-
448
- const cubit = new CounterCubit();
449
- cubit.addPlugin(validationPlugin);
450
- cubit.addPlugin(persistencePlugin);
451
- Blac.activateBloc(cubit as any);
452
-
453
- cubit.setValue(5);
454
- expect(cubit.state).toBe(5);
455
-
456
- cubit.setValue(15);
457
- expect(cubit.state).toBe(5); // Validation rejected
458
-
459
- setTimeout(() => {
460
- expect(storage.getItem('validated-counter')).toBe('5');
461
- }, 10);
462
- });
463
- });
464
- });