mirror of https://github.com/buster-so/buster.git
fix: add optional chaining to ls_files tests for TypeScript strict null checks
- Follow patterns from read-files and edit-files tests - Use optional chaining (?.) for array access to handle 'Object is possibly undefined' errors - Fixes CI TypeScript compilation errors on lines 54, 55, 56, 65, 141, 142, 143 Co-Authored-By: Dallin Bentley <dallinbentley98@gmail.com>
This commit is contained in:
parent
096cd26355
commit
fe77b4e3a8
|
@ -51,9 +51,9 @@ drwxr-xr-x 2 user group 4096 Jan 15 10:31 directory1`;
|
|||
const result = await lsFilesSafely(['/test/path'], options);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].success).toBe(true);
|
||||
expect(result[0].entries).toHaveLength(2);
|
||||
expect(result[0].entries?.[0]).toEqual({
|
||||
expect(result[0]?.success).toBe(true);
|
||||
expect(result[0]?.entries).toHaveLength(2);
|
||||
expect(result[0]?.entries?.[0]).toEqual({
|
||||
name: 'file1.txt',
|
||||
type: 'file',
|
||||
size: '1024',
|
||||
|
@ -62,7 +62,7 @@ drwxr-xr-x 2 user group 4096 Jan 15 10:31 directory1`;
|
|||
owner: 'user',
|
||||
group: 'group',
|
||||
});
|
||||
expect(result[0].entries?.[1]).toEqual({
|
||||
expect(result[0]?.entries?.[1]).toEqual({
|
||||
name: 'directory1',
|
||||
type: 'directory',
|
||||
size: '4096',
|
||||
|
@ -138,9 +138,9 @@ drwxr-xr-x 2 user group 4096 Jan 15 10:31 directory1`;
|
|||
const result = await lsFilesSafely(['/good/path', '/bad/path']);
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].success).toBe(true);
|
||||
expect(result[1].success).toBe(false);
|
||||
expect(result[1].error).toBe('Path not found');
|
||||
expect(result[0]?.success).toBe(true);
|
||||
expect(result[1]?.success).toBe(false);
|
||||
expect(result[1]?.error).toBe('Path not found');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue