Files
wehub-resource-sync 070959e133
landing-page-staging / Deploy landing page to staging (push) Has been skipped
landing-page-ci / Validate landing page (push) Failing after 4s
visual-baseline / Capture visual baselines (push) Has been cancelled
bake-plugin-previews / Bake plugin previews (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:00:47 +08:00

28 lines
1005 B
TypeScript

import { describe, expect, it } from 'vitest';
import {
FILE_SYSTEM_READ_ERROR_MESSAGE,
createFileSystemReadError,
isFileSystemReadError,
} from '../../src/utils/fileSystemErrors';
describe('createFileSystemReadError', () => {
it('wraps DOMException-like file system failures in a stack-bearing Error', () => {
const cause = new DOMException(
'A requested file or directory could not be found at the time an operation was processed.',
'NotFoundError',
);
const error = createFileSystemReadError('Could not read dropped file', cause);
expect(error).toBeInstanceOf(Error);
expect(error.name).toBe('FileSystemReadError');
expect(error.message).toContain('Could not read dropped file');
expect(error.message).toContain('NotFoundError');
expect(error.cause).toBe(cause);
expect(error.stack).toEqual(expect.any(String));
expect(isFileSystemReadError(error)).toBe(true);
expect(FILE_SYSTEM_READ_ERROR_MESSAGE).toContain('try again');
});
});