Refactor tests in useGitOperations and useWorkspaceOperations to handle undefined values gracefully

This commit is contained in:
2025-05-28 21:04:43 +02:00
parent b38792a47f
commit 907dffe362
2 changed files with 13 additions and 149 deletions

View File

@@ -380,7 +380,7 @@ describe('useGitOperations', () => {
it('handles undefined workspace name gracefully', async () => {
mockWorkspaceData.currentWorkspace = {
id: 1,
name: undefined as unknown as string,
name: undefined!,
};
const { result } = renderHook(() => useGitOperations());
@@ -396,7 +396,7 @@ describe('useGitOperations', () => {
it('handles missing settings gracefully', async () => {
mockWorkspaceData.settings = {
gitEnabled: undefined as unknown as boolean,
gitEnabled: undefined!,
};
const { result } = renderHook(() => useGitOperations());
@@ -413,7 +413,7 @@ describe('useGitOperations', () => {
it('handles API returning non-string commit hash', async () => {
const mockCommitAndPush = vi.mocked(gitApi.commitAndPush);
// API might return something unexpected
mockCommitAndPush.mockResolvedValue(null as unknown as string);
mockCommitAndPush.mockResolvedValue(null!);
const { result } = renderHook(() => useGitOperations());