mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-27 07:14:41 +02:00
* refactor(gh): unify frontend diagnostics * refactor(gh): unify frontend diagnostics markdown rendering * docs(gh): restore frontend diagnostics comments * wip * fix * refactor: 呼称をbase/headに統一 * tweak * Update types.ts * fix
30 lines
839 B
TypeScript
30 lines
839 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { promises as fs } from 'node:fs';
|
|
import { afterEach, expect, test, vi } from 'vitest';
|
|
import { fileExists } from '../../src/bundle/fs-utils';
|
|
|
|
function fsError(code: string) {
|
|
return Object.assign(new Error(`fs error: ${code}`), { code }) as NodeJS.ErrnoException;
|
|
}
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
test('fileExists returns false for ENOENT', async () => {
|
|
vi.spyOn(fs, 'access').mockRejectedValueOnce(fsError('ENOENT'));
|
|
|
|
await expect(fileExists('missing')).resolves.toBe(false);
|
|
});
|
|
|
|
test('fileExists rethrows errors other than ENOENT', async () => {
|
|
const error = fsError('EACCES');
|
|
vi.spyOn(fs, 'access').mockRejectedValueOnce(error);
|
|
|
|
await expect(fileExists('restricted')).rejects.toBe(error);
|
|
});
|