22 * Unit tests for Form State Manager
33 */
44
5- import { describe , it , expect , beforeEach } from 'vitest' ;
5+ import { describe , it , expect , beforeEach , vi } from 'vitest' ;
66import { FormStateManager } from './form-state-manager' ;
77import { ValidationResult , StateChangeEvent } from '../types/core' ;
88
@@ -214,7 +214,7 @@ describe('FormStateManager', () => {
214214
215215 describe ( 'state change subscriptions' , ( ) => {
216216 it ( 'should notify subscribers of field changes' , ( ) => {
217- const callback = jest . fn ( ) ;
217+ const callback = vi . fn ( ) ;
218218 const subscription = stateManager . subscribeToChanges ( callback ) ;
219219
220220 stateManager . updateField ( 'email' , 'test@example.com' ) ;
@@ -232,7 +232,7 @@ describe('FormStateManager', () => {
232232 } ) ;
233233
234234 it ( 'should notify subscribers of validation changes' , ( ) => {
235- const callback = jest . fn ( ) ;
235+ const callback = vi . fn ( ) ;
236236 stateManager . subscribeToChanges ( callback ) ;
237237
238238 const validationResult : ValidationResult = {
@@ -252,10 +252,10 @@ describe('FormStateManager', () => {
252252 } ) ;
253253
254254 it ( 'should handle subscription errors gracefully' , ( ) => {
255- const errorCallback = jest . fn ( ( ) => {
256- throw new Error ( 'Callback error' ) ;
255+ const errorCallback = vi . fn ( ( ) => {
256+ throw new Error ( 'subscription error' ) ;
257257 } ) ;
258- const normalCallback = jest . fn ( ) ;
258+ const normalCallback = vi . fn ( ) ;
259259
260260 stateManager . subscribeToChanges ( errorCallback ) ;
261261 stateManager . subscribeToChanges ( normalCallback ) ;
@@ -269,7 +269,7 @@ describe('FormStateManager', () => {
269269 } ) ;
270270
271271 it ( 'should unsubscribe correctly' , ( ) => {
272- const callback = jest . fn ( ) ;
272+ const callback = vi . fn ( ) ;
273273 const subscription = stateManager . subscribeToChanges ( callback ) ;
274274
275275 stateManager . updateField ( 'email' , 'test1@example.com' ) ;
@@ -333,7 +333,7 @@ describe('FormStateManager', () => {
333333 describe ( 'programmatic state control methods' , ( ) => {
334334 describe ( 'silent field updates' , ( ) => {
335335 it ( 'should set field value without triggering change events' , ( ) => {
336- const callback = jest . fn ( ) ;
336+ const callback = vi . fn ( ) ;
337337 stateManager . subscribeToChanges ( callback ) ;
338338
339339 stateManager . setFieldValueSilently ( 'email' , 'test@example.com' ) ;
@@ -345,7 +345,7 @@ describe('FormStateManager', () => {
345345
346346 describe ( 'batch operations' , ( ) => {
347347 it ( 'should set multiple validation states at once' , ( ) => {
348- const callback = jest . fn ( ) ;
348+ const callback = vi . fn ( ) ;
349349 stateManager . subscribeToChanges ( callback ) ;
350350
351351 const validationStates = {
@@ -364,7 +364,7 @@ describe('FormStateManager', () => {
364364 } ) ;
365365
366366 it ( 'should set multiple field values in batch' , ( ) => {
367- const callback = jest . fn ( ) ;
367+ const callback = vi . fn ( ) ;
368368 stateManager . subscribeToChanges ( callback ) ;
369369
370370 const values = {
@@ -471,15 +471,15 @@ describe('FormStateManager', () => {
471471
472472 describe ( 'submission control' , ( ) => {
473473 it ( 'should start submission with callback' , ( ) => {
474- const callback = jest . fn ( ) ;
474+ const callback = vi . fn ( ) ;
475475 stateManager . startSubmission ( callback ) ;
476476
477477 expect ( stateManager . getState ( ) . isSubmitting ) . toBe ( true ) ;
478478 expect ( callback ) . toHaveBeenCalled ( ) ;
479479 } ) ;
480480
481481 it ( 'should complete submission successfully' , ( ) => {
482- const callback = jest . fn ( ) ;
482+ const callback = vi . fn ( ) ;
483483
484484 // Set up dirty state
485485 stateManager . updateField ( 'email' , 'test@example.com' ) ;
@@ -493,7 +493,7 @@ describe('FormStateManager', () => {
493493 } ) ;
494494
495495 it ( 'should complete submission with failure' , ( ) => {
496- const callback = jest . fn ( ) ;
496+ const callback = vi . fn ( ) ;
497497
498498 // Set up dirty state
499499 stateManager . updateField ( 'email' , 'test@example.com' ) ;
@@ -686,7 +686,7 @@ describe('FormStateManager', () => {
686686 } ) ;
687687
688688 it ( 'should trigger cascading updates manually' , ( ) => {
689- const callback = jest . fn ( ) ;
689+ const callback = vi . fn ( ) ;
690690 stateManager . subscribeToChanges ( callback ) ;
691691
692692 stateManager . updateField ( 'trigger' , 'show' ) ;
0 commit comments