@@ -8,7 +8,7 @@ import { startFileWatcher } from "@/lib/watcher";
88import http from "http" ;
99import path from "path" ;
1010import { Server as IoServer } from "socket.io" ;
11- import { Gaze } from "gaze " ;
11+ import chokidar from "chokidar " ;
1212
1313import { vol } from 'memfs' ;
1414jest . mock ( 'fs' , ( ) => require ( 'memfs' ) . fs ) ;
@@ -43,7 +43,6 @@ describe("dev", () => {
4343 ( loadConfig as jest . MockedFunction < typeof loadConfig > ) . mockResolvedValue ( mockConfig ) ;
4444 ( startDevServer as jest . MockedFunction < typeof startDevServer > ) . mockReturnValue ( { } as http . Server ) ;
4545 ( startSocket as jest . MockedFunction < typeof startSocket > ) . mockReturnValue ( new IoServer ( ) ) ;
46- ( startFileWatcher as jest . MockedFunction < typeof startFileWatcher > ) . mockReturnValue ( new Gaze ( mockSrc ) ) ;
4746 ( buildApp as jest . MockedFunction < typeof buildApp > ) . mockReturnValue ( { } as Promise < any > ) ;
4847 } ) ;
4948
@@ -89,8 +88,16 @@ describe("dev", () => {
8988 } ) ;
9089
9190 it ( "should add correct watch paths after adding apps" , async ( ) => {
92- const mockedGazeAdd = jest . spyOn ( Gaze . prototype , 'add' ) ;
93-
91+ const mockAdd = jest . fn ( ) ;
92+ const mockWatch = jest . fn ( ) . mockReturnValue ( {
93+ add : mockAdd ,
94+ } ) ;
95+ ( chokidar . watch as jest . Mock ) = mockWatch ;
96+
97+ ( startFileWatcher as jest . MockedFunction < typeof startFileWatcher > ) . mockReturnValue (
98+ mockWatch ( [ ] , { } ) as chokidar . FSWatcher
99+ ) ;
100+
94101 const mockOpts : DevOptions = { hot : false } ;
95102 await dev ( mockSrc , "build" , mockOpts ) ;
96103
@@ -106,6 +113,6 @@ describe("dev", () => {
106113 path . join ( mockSrc2 , 'bos.config.json' ) ,
107114 path . join ( mockSrc2 , 'aliases.json' ) ,
108115 ] ;
109- expect ( mockedGazeAdd ) . toHaveBeenCalledWith ( expectedWatchPaths ) ;
116+ expect ( mockAdd ) . toHaveBeenCalledWith ( expectedWatchPaths ) ;
110117 } ) ;
111118} ) ;
0 commit comments