1- import { LiftedActions , ComputedState , LiftedAction } from './../src/reducer' ;
2- import { PerformAction , PERFORM_ACTION } from './../src/actions' ;
1+ import { ComputedState , LiftedAction , LiftedActions } from './../src/reducer' ;
2+ import { PERFORM_ACTION , PerformAction } from './../src/actions' ;
33import {
4- ReduxDevtoolsExtensionConnection ,
5- ReduxDevtoolsExtensionConfig ,
6- REDUX_DEVTOOLS_EXTENSION ,
74 ExtensionActionTypes ,
5+ REDUX_DEVTOOLS_EXTENSION ,
6+ ReduxDevtoolsExtensionConfig ,
7+ ReduxDevtoolsExtensionConnection ,
88} from './../src/extension' ;
99import { Action } from '@ngrx/store' ;
1010
@@ -18,7 +18,7 @@ import {
1818import { unliftState } from '../src/utils' ;
1919import { TestBed } from '@angular/core/testing' ;
2020import { DevtoolsDispatcher } from '../src/devtools-dispatcher' ;
21- import { inject } from '@angular/core ' ;
21+ import { Mock , vi } from 'vitest ' ;
2222
2323function createOptions (
2424 name = 'NgRx Store DevTools' ,
@@ -84,21 +84,19 @@ function createState(
8484
8585const testSetup = ( options : { config : StoreDevtoolsConfig } ) => {
8686 const reduxDevtoolsExtension = {
87- send : jasmine . createSpy ( 'send' ) ,
88- connect : jasmine . createSpy ( 'connect' ) ,
87+ send : vi . fn ( ) ,
88+ connect : vi . fn ( ) ,
8989 } ;
9090
9191 const extensionConnection = {
92- init : jasmine . createSpy ( 'init' ) ,
93- subscribe : jasmine . createSpy ( 'subscribe' ) ,
94- unsubscribe : jasmine . createSpy ( 'unsubscribe' ) ,
95- send : jasmine . createSpy ( 'send' ) ,
96- error : jasmine . createSpy ( 'error' ) ,
92+ init : vi . fn ( ) ,
93+ subscribe : vi . fn ( ) ,
94+ unsubscribe : vi . fn ( ) ,
95+ send : vi . fn ( ) ,
96+ error : vi . fn ( ) ,
9797 } ;
9898
99- ( reduxDevtoolsExtension . connect as jasmine . Spy ) . and . returnValue (
100- extensionConnection
101- ) ;
99+ reduxDevtoolsExtension . connect . mockReturnValue ( extensionConnection ) ;
102100
103101 TestBed . configureTestingModule ( {
104102 // Provide both the service-to-test and its (spy) dependency
@@ -179,7 +177,7 @@ describe('DevtoolsExtension', () => {
179177 // Subscription needed or else extension connection will not be established.
180178 devtoolsExtension . actions$ . subscribe ( ( ) => null ) ;
181179 expect ( reduxDevtoolsExtension . connect ) . toHaveBeenCalledWith (
182- jasmine . objectContaining ( { serialize : customSerializer } )
180+ expect . objectContaining ( { serialize : customSerializer } )
183181 ) ;
184182 } ) ;
185183
@@ -202,7 +200,7 @@ describe('DevtoolsExtension', () => {
202200 return ( unwrappedAction = action ) ;
203201 } ) ;
204202
205- const [ callback ] = extensionConnection . subscribe . calls . mostRecent ( ) . args ;
203+ const [ callback ] = extensionConnection . subscribe . mock . lastCall ;
206204 callback ( { type : ExtensionActionTypes . START } ) ;
207205 callback ( { type : ExtensionActionTypes . ACTION , payload } ) ;
208206 expect ( unwrappedAction ) . toEqual ( {
@@ -541,14 +539,12 @@ describe('DevtoolsExtension', () => {
541539 const NORMAL_ACTION = 'NORMAL_ACTION' ;
542540 const RANDOM_ACTION = 'RANDOM_ACTION' ;
543541
544- const predicate = jasmine
545- . createSpy ( 'predicate' , ( state : any , action : Action ) => {
546- if ( action . type === RANDOM_ACTION ) {
547- return false ;
548- }
549- return true ;
550- } )
551- . and . callThrough ( ) ;
542+ const predicate = vi . fn ( ( state : any , action : Action ) => {
543+ if ( action . type === RANDOM_ACTION ) {
544+ return false ;
545+ }
546+ return true ;
547+ } ) ;
552548
553549 let devtoolsExtension : DevtoolsExtension ;
554550 let extensionConnection : ReduxDevtoolsExtensionConnection ;
@@ -669,7 +665,7 @@ describe('DevtoolsExtension', () => {
669665 } ) ;
670666
671667 describe ( 'error handling' , ( ) => {
672- let consoleSpy : jasmine . Spy ;
668+ let consoleSpy : Mock ;
673669
674670 let devtoolsExtension : DevtoolsExtension ;
675671 let extensionConnection : ReduxDevtoolsExtensionConnection ;
@@ -682,11 +678,11 @@ describe('DevtoolsExtension', () => {
682678 } ) ) ;
683679 // Subscription needed or else extension connection will not be established.
684680 devtoolsExtension . actions$ . subscribe ( ) ;
685- consoleSpy = spyOn ( console , 'warn' ) ;
681+ consoleSpy = vi . spyOn ( console , 'warn' ) ;
686682 } ) ;
687683
688684 it ( 'for normal action' , ( ) => {
689- ( extensionConnection . send as jasmine . Spy ) . and . callFake ( ( ) => {
685+ ( extensionConnection . send as Mock ) . mockImplementation ( ( ) => {
690686 throw new Error ( 'uh-oh something went wrong' ) ;
691687 } ) ;
692688
@@ -698,7 +694,7 @@ describe('DevtoolsExtension', () => {
698694 } ) ;
699695
700696 it ( 'for action that requires full state update' , ( ) => {
701- ( reduxDevtoolsExtension . send as jasmine . Spy ) . and . callFake ( ( ) => {
697+ ( reduxDevtoolsExtension . send as Mock ) . mockImplementation ( ( ) => {
702698 throw new Error ( 'uh-oh something went wrong' ) ;
703699 } ) ;
704700
0 commit comments