@@ -104,12 +104,8 @@ suite('Package Watcher', () => {
104104 mockLogOutputChannel as LogOutputChannel ,
105105 ) ;
106106
107- // Should create watchers for site-packages and conda-meta
108- assert . strictEqual (
109- createFileSystemWatcherStub . callCount ,
110- 2 ,
111- 'Should create 2 watchers (site-packages + conda-meta)' ,
112- ) ;
107+ // Default should create watcher for site-packages metadata.
108+ assert . strictEqual ( createFileSystemWatcherStub . callCount , 1 , 'Should create 1 watcher (site-packages)' ) ;
113109 } ) ;
114110
115111 test ( 'should create correct watch patterns on Windows' , ( ) => {
@@ -174,24 +170,35 @@ suite('Package Watcher', () => {
174170 }
175171 } ) ;
176172
177- test ( 'should watch conda-meta for conda packages ' , ( ) => {
173+ test ( 'should append package-manager-provided watch targets to defaults ' , ( ) => {
178174 const mockWatcher = createMockWatcher ( ) ;
179175 createFileSystemWatcherStub . returns ( mockWatcher ) ;
180176
181177 const env = createMockEnvironment ( { sysPrefix : '/path/to/env' } ) ;
182178 const packageManager = createMockPackageManager ( ) ;
179+ ( packageManager as PackageManager ) . getPackageWatchTargets = ( ) => [
180+ new RelativePattern ( '/path/to/env/conda-meta' , '**/*.json' ) ,
181+ ] ;
183182
184183 watchPackageChangesForEnvironment (
185184 env ,
186185 packageManager as PackageManager ,
187186 mockLogOutputChannel as LogOutputChannel ,
188187 ) ;
189188
189+ assert . strictEqual ( createFileSystemWatcherStub . callCount , 2 , 'Should watch default and custom targets' ) ;
190+
191+ const firstCall = createFileSystemWatcherStub . getCall ( 0 ) ;
192+ const firstPattern = firstCall . args [ 0 ] as RelativePattern ;
190193 const secondCall = createFileSystemWatcherStub . getCall ( 1 ) ;
191- const pattern = secondCall . args [ 0 ] as RelativePattern ;
194+ const secondPattern = secondCall . args [ 0 ] as RelativePattern ;
192195
193- assert . ok ( pattern . baseUri . fsPath . includes ( 'conda-meta' ) , 'Should watch conda-meta' ) ;
194- assert . strictEqual ( pattern . pattern , '**/*.json' , 'Should watch JSON files in conda-meta' ) ;
196+ assert . ok (
197+ firstPattern . pattern . endsWith ( 'site-packages/**/*.dist-info/METADATA' ) ,
198+ 'Should keep default site-packages watcher' ,
199+ ) ;
200+ assert . ok ( secondPattern . baseUri . fsPath . includes ( 'conda-meta' ) , 'Should append conda-meta target' ) ;
201+ assert . strictEqual ( secondPattern . pattern , '**/*.json' , 'Should watch JSON files in conda-meta' ) ;
195202 } ) ;
196203
197204 test ( 'should call packageManager.refresh on file create' , ( ) => {
@@ -207,12 +214,9 @@ suite('Package Watcher', () => {
207214 mockLogOutputChannel as LogOutputChannel ,
208215 ) ;
209216
210- // Verify watchers are created which will have create event handlers
211- assert . strictEqual (
212- createFileSystemWatcherStub . callCount ,
213- 2 ,
214- 'Should create watchers for site-packages and conda-meta' ,
215- ) ;
217+ // Verify watcher is created and create events are observed.
218+ assert . strictEqual ( createFileSystemWatcherStub . callCount , 1 , 'Should create watcher for site-packages' ) ;
219+ assert . strictEqual ( createFileSystemWatcherStub . getCall ( 0 ) . args [ 1 ] , false , 'Should watch create events' ) ;
216220 } ) ;
217221
218222 test ( 'should call packageManager.refresh on file delete' , ( ) => {
@@ -228,12 +232,9 @@ suite('Package Watcher', () => {
228232 mockLogOutputChannel as LogOutputChannel ,
229233 ) ;
230234
231- // Verify watchers are created which will have delete event handlers
232- assert . strictEqual (
233- createFileSystemWatcherStub . callCount ,
234- 2 ,
235- 'Should create watchers for site-packages and conda-meta' ,
236- ) ;
235+ // Verify watcher is created and delete events are observed.
236+ assert . strictEqual ( createFileSystemWatcherStub . callCount , 1 , 'Should create watcher for site-packages' ) ;
237+ assert . strictEqual ( createFileSystemWatcherStub . getCall ( 0 ) . args [ 3 ] , false , 'Should watch delete events' ) ;
237238 } ) ;
238239
239240 test ( 'should debounce multiple rapid file events' , ( ) => {
@@ -249,11 +250,11 @@ suite('Package Watcher', () => {
249250 mockLogOutputChannel as LogOutputChannel ,
250251 ) ;
251252
252- // Verify watchers are created with event handlers for debouncing
253+ // Verify watcher is created with event handlers for debouncing.
253254 assert . strictEqual (
254255 createFileSystemWatcherStub . callCount ,
255- 2 ,
256- 'Should create watchers with debounced event handlers' ,
256+ 1 ,
257+ 'Should create watcher with debounced event handlers' ,
257258 ) ;
258259 } ) ;
259260
0 commit comments