项目文件夹

文件
wehub-resource-sync 2771cff92b
CI / lint (push) Failing after 1s
CI / typecheck (push) Failing after 2s
CI / test (push) Failing after 1s
CI / build (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:22:56 +08:00

35 行
1.2 KiB
TypeScript

import { Notice } from 'obsidian';
import { NotifiedMutationError } from '@/core/storage/NotifiedMutationError';
import { McpTestModal } from '@/shared/settings/McpTestModal';
describe('McpTestModal mutation failures', () => {
it('rolls back without duplicating a storage-owned Notice', async () => {
const modal = Object.create(McpTestModal.prototype) as McpTestModal;
const checkbox = { checked: false, disabled: false } as HTMLInputElement;
const container = { toggleClass: jest.fn() } as unknown as HTMLElement;
Object.assign(modal, {
disabledTools: new Set<string>(),
onToolToggle: jest.fn().mockRejectedValue(
new NotifiedMutationError(
'Failed to update .claude/mcp.json because it contains invalid JSON.',
),
),
toolElements: new Map([['alpha', {} as HTMLElement]]),
updateToggleAllButton: jest.fn(),
updateToolState: jest.fn(),
});
await (modal as unknown as {
handleToolToggle: (
toolName: string,
checkbox: HTMLInputElement,
container: HTMLElement,
) => Promise<void>;
}).handleToolToggle('alpha', checkbox, container);
expect(checkbox.checked).toBe(true);
expect(Notice).not.toHaveBeenCalled();
});
});