import { describe, expect, it, vi } from 'vitest';
import React, { isValidElement } from 'react';

vi.mock('expo-router', () => ({
  router: { push: vi.fn() },
}));

vi.mock('../../store/notes-store', () => ({
  useNotesStore: (selector: (state: {
    notes: Array<{ id: string; title: string; workspaceName: string; body: string }>;
    isLoading: boolean;
  }) => unknown) =>
    selector({
      notes: [
        { id: 'n1', title: 'Test note', workspaceName: 'Work', body: 'Body text' },
      ],
      isLoading: false,
    }),
}));

vi.mock('../../store/workspace-store', () => ({
  useWorkspaceStore: (selector: (state: {
    workspaces: Array<{ id: string; name: string }>;
    activeWorkspaceId: string | null;
    setActiveWorkspace: (id: string | null) => void;
  }) => unknown) =>
    selector({
      workspaces: [{ id: 'ws-1', name: 'Work' }],
      activeWorkspaceId: null,
      setActiveWorkspace: vi.fn(),
    }),
}));

import HomeScreen from './index';

describe('HomeScreen', () => {
  it('is a valid React component', () => {
    expect(typeof HomeScreen).toBe('function');
    const element = React.createElement(HomeScreen);
    expect(isValidElement(element)).toBe(true);
  });

  it('exports as default', () => {
    expect(HomeScreen).toBeDefined();
    expect(HomeScreen.name).toBe('HomeScreen');
  });
});
