| 378 | } |
| 379 | |
| 380 | function makeFakeInstance(sftp: unknown, cwd: string): SSHKaos { |
| 381 | // Bypass the real constructor (which requires a live ssh2 client) and |
| 382 | // populate just the private fields that chdir touches. |
| 383 | const instance = Object.create(SSHKaos.prototype) as SSHKaos; |
| 384 | const internal = instance as unknown as { _sftp: unknown; _cwd: string }; |
| 385 | internal._sftp = sftp; |
| 386 | internal._cwd = cwd; |
| 387 | return instance; |
| 388 | } |
| 389 | |
| 390 | it('rejects a target that resolves to a regular file', async () => { |
| 391 | const target = '/tmp/not-a-dir.txt'; |