@@ -124,10 +124,10 @@ describe('files-watcher subscribe / unsubscribe', () => {
124124 expect ( watchMock ) . not . toHaveBeenCalled ( ) ;
125125 } ) ;
126126
127- it ( 'rejects when the watcher cannot start ' , ( ) => {
127+ it ( 'rejects when the watcher throws a non-system error ' , ( ) => {
128128 reset ( ) ;
129129 watchMock . mockImplementation ( ( ) => {
130- throw new Error ( 'watch denied ' ) ;
130+ throw new Error ( 'watcher implementation bug ' ) ;
131131 } ) ;
132132 getDesignMock . mockReturnValue ( {
133133 id : 'd1' ,
@@ -136,21 +136,24 @@ describe('files-watcher subscribe / unsubscribe', () => {
136136 registerFilesWatcherIpc ( { } as never , ( ) => null ) ;
137137 const sub = getHandler ( 'codesign:files:v1:subscribe' ) ;
138138
139- const err = captureError ( ( ) => sub ( null , { schemaVersion : 1 , designId : 'd1' } ) ) ;
139+ const caught = captureError ( ( ) => sub ( null , { schemaVersion : 1 , designId : 'd1' } ) ) ;
140140
141- expect ( err ) . toMatchObject ( { name : 'CodesignError' , code : 'IPC_DB_ERROR' } ) ;
141+ expect ( caught ) . toMatchObject ( { name : 'CodesignError' , code : 'IPC_DB_ERROR' } ) ;
142142 expect ( watchMock ) . toHaveBeenCalledTimes ( 1 ) ;
143143 } ) ;
144144
145- it ( 'does not reject when the bound workspace folder is missing' , ( ) => {
145+ it . each ( [
146+ 'ENOENT' ,
147+ 'ENOTDIR' ,
148+ ] ) ( 'does not reject when the bound workspace is unavailable with %s' , ( code ) => {
146149 reset ( ) ;
147- const err = Object . assign ( new Error ( 'no such file or directory ' ) , { code : 'ENOENT' } ) ;
150+ const err = Object . assign ( new Error ( 'workspace unavailable ' ) , { code } ) ;
148151 watchMock . mockImplementation ( ( ) => {
149152 throw err ;
150153 } ) ;
151154 getDesignMock . mockReturnValue ( {
152155 id : 'd1' ,
153- workspacePath : tempWorkspace ( ' codesign-watch-missing' ) ,
156+ workspacePath : tempWorkspace ( ` codesign-watch-${ code . toLowerCase ( ) } ` ) ,
154157 } ) ;
155158 registerFilesWatcherIpc ( { } as never , ( ) => null ) ;
156159 const sub = getHandler ( 'codesign:files:v1:subscribe' ) ;
@@ -162,11 +165,15 @@ describe('files-watcher subscribe / unsubscribe', () => {
162165 } ) ;
163166
164167 it . each ( [
165- [ 'permission denial' , 'EPERM' ] ,
166- [ 'unsupported directory watch' , 'EISDIR' ] ,
167- ] ) ( 'falls back to polling when native watch fails from %s' , ( _reason , code ) => {
168+ 'EPERM' ,
169+ 'EACCES' ,
170+ 'EISDIR' ,
171+ 'EINVAL' ,
172+ 'ENOSPC' ,
173+ 'ERR_FEATURE_UNAVAILABLE_ON_PLATFORM' ,
174+ ] ) ( 'falls back to polling when native watch fails with %s' , ( code ) => {
168175 reset ( ) ;
169- const err = Object . assign ( new Error ( 'watch unavailable' ) , { code } ) ;
176+ const err = Object . assign ( new Error ( 'native watch unavailable' ) , { code } ) ;
170177 watchMock . mockImplementation ( ( ) => {
171178 throw err ;
172179 } ) ;
0 commit comments